Browse Source

Don't error if an invalid setting is given.

git-svn-id: http://svn.redmine.org/redmine/trunk@15730 e93f8b46-1217-0410-a6f0-8f06a7374b81
tags/3.4.0
Jean-Philippe Lang 7 years ago
parent
commit
596a196f2e
2 changed files with 12 additions and 1 deletions
  1. 3
    1
      app/models/setting.rb
  2. 9
    0
      test/functional/settings_controller_test.rb

+ 3
- 1
app/models/setting.rb View File

@@ -120,9 +120,11 @@ class Setting < ActiveRecord::Base

# Updates multiple settings from params and sends a security notification if needed
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 = []
settings.each do |name, value|
next unless available_settings[name.to_s]
previous_value = Setting[name]
set_from_params name, value
if available_settings[name.to_s]['security_notifications'] && Setting[name] != previous_value

+ 9
- 0
test/functional/settings_controller_test.rb View File

@@ -145,6 +145,15 @@ class SettingsControllerTest < Redmine::ControllerTest
], Setting.commit_update_keywords)
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
ActionMailer::Base.deliveries.clear
post :edit, :params => {

Loading…
Cancel
Save