1
0
mirror of https://github.com/meineerde/redmine.git synced 2025-12-19 15:01:14 +00:00

Don't error if an invalid setting is given.

git-svn-id: http://svn.redmine.org/redmine/trunk@15730 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2016-07-21 18:14:13 +00:00
parent fcd8ace743
commit 596a196f2e
2 changed files with 12 additions and 1 deletions

View File

@ -120,9 +120,11 @@ class Setting < ActiveRecord::Base
# Updates multiple settings from params and sends a security notification if needed # Updates multiple settings from params and sends a security notification if needed
def self.set_all_from_params(settings) def self.set_all_from_params(settings)
settings = (settings || {}).dup.symbolize_keys return false unless settings.is_a?(Hash)
settings = settings.dup.symbolize_keys
changes = [] changes = []
settings.each do |name, value| settings.each do |name, value|
next unless available_settings[name.to_s]
previous_value = Setting[name] previous_value = Setting[name]
set_from_params name, value set_from_params name, value
if available_settings[name.to_s]['security_notifications'] && Setting[name] != previous_value if available_settings[name.to_s]['security_notifications'] && Setting[name] != previous_value

View File

@ -145,6 +145,15 @@ class SettingsControllerTest < Redmine::ControllerTest
], Setting.commit_update_keywords) ], Setting.commit_update_keywords)
end end
def test_post_edit_with_invalid_setting_should_not_error
post :edit, :params => {
:settings => {
:invalid_setting => '1'
}
}
assert_redirected_to '/settings'
end
def test_post_edit_should_send_security_notification_for_notified_settings def test_post_edit_should_send_security_notification_for_notified_settings
ActionMailer::Base.deliveries.clear ActionMailer::Base.deliveries.clear
post :edit, :params => { post :edit, :params => {