mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-04-08 23:53:53 +02:00
(bug) unable to bulk_update settings
This commit is contained in:
parent
68bee8c3e3
commit
7e36d49035
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
- Italian language support (credits to https://crowdin.com/profile/olazzari)
|
- Italian language support (credits to https://crowdin.com/profile/olazzari)
|
||||||
- Fix a bug: broken admin notifications if an order has been paid
|
- Fix a bug: broken admin notifications if an order has been paid
|
||||||
|
- Fix a bug: unable to bulk update settings
|
||||||
|
|
||||||
## v6.0.1 2023 April 03
|
## v6.0.1 2023 April 03
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
json.settings @settings.each do |setting|
|
json.settings @settings.each do |setting|
|
||||||
if setting.errors.keys.count.positive?
|
if setting.errors.count.positive?
|
||||||
json.error setting.errors.full_messages
|
json.error setting.errors.full_messages
|
||||||
json.id setting.id
|
json.id setting.id
|
||||||
json.name setting.name
|
json.name setting.name
|
||||||
|
@ -31,6 +31,38 @@ class SettingsTest < ActionDispatch::IntegrationTest
|
|||||||
assert_includes setting.history_values.map(&:value), 'Test Fablab', 'current parameter was not saved'
|
assert_includes setting.history_values.map(&:value), 'Test Fablab', 'current parameter was not saved'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test 'bulk update some settings' do
|
||||||
|
patch '/api/settings/bulk_update',
|
||||||
|
params: {
|
||||||
|
settings: [
|
||||||
|
{ name: 'fablab_name', value: 'Test Fablab' },
|
||||||
|
{ name: 'name_genre', value: 'male' },
|
||||||
|
{ name: 'main_color', value: '#ea519a' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
assert_equal 200, response.status
|
||||||
|
assert_match Mime[:json].to_s, response.content_type
|
||||||
|
resp = json_response(response.body)
|
||||||
|
assert(resp[:settings].any? { |s| s[:name] == 'fablab_name' && s[:value] == 'Test Fablab' })
|
||||||
|
assert(resp[:settings].any? { |s| s[:name] == 'name_genre' && s[:value] == 'male' })
|
||||||
|
assert(resp[:settings].any? { |s| s[:name] == 'main_color' && s[:value] == '#ea519a' })
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'transactional bulk update fails' do
|
||||||
|
patch '/api/settings/bulk_update?transactional=true',
|
||||||
|
params: {
|
||||||
|
settings: [
|
||||||
|
{ name: 'home_css', value: 'INVALID CSS{{!!' },
|
||||||
|
{ name: 'main_color', value: '#ea519a' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
assert_equal 200, response.status
|
||||||
|
assert_match Mime[:json].to_s, response.content_type
|
||||||
|
resp = json_response(response.body)
|
||||||
|
assert_not_nil resp[:settings].first[:error]
|
||||||
|
assert_match(/Error: Invalid CSS after/, resp[:settings].first[:error].first)
|
||||||
|
end
|
||||||
|
|
||||||
test 'update setting with wrong name' do
|
test 'update setting with wrong name' do
|
||||||
put '/api/settings/does_not_exists',
|
put '/api/settings/does_not_exists',
|
||||||
params: {
|
params: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user