diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2017-07-16 11:47:55 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2017-07-16 11:47:55 +0000 |
commit | 7e9805aa953e65deadbded802ec76cecac8f595f (patch) | |
tree | d89f648df56f00a6b03be2fcc220995dbe5bb965 | |
parent | 6e16ab0c60690dc09b7499e55f7060c294c6b95d (diff) | |
download | redmine-7e9805aa953e65deadbded802ec76cecac8f595f.tar.gz redmine-7e9805aa953e65deadbded802ec76cecac8f595f.zip |
Merged r16812 (#26393).
git-svn-id: http://svn.redmine.org/redmine/branches/3.4-stable@16817 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/controllers/settings_controller.rb | 3 | ||||
-rw-r--r-- | test/functional/settings_controller_test.rb | 14 |
2 files changed, 16 insertions, 1 deletions
diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb index 51ab871ca..7b2dceb31 100644 --- a/app/controllers/settings_controller.rb +++ b/app/controllers/settings_controller.rb @@ -67,7 +67,8 @@ class SettingsController < ApplicationController end if request.post? - Setting.send "plugin_#{@plugin.id}=", params[:settings].permit!.to_h + setting = params[:settings] ? params[:settings].permit!.to_h : {} + Setting.send "plugin_#{@plugin.id}=", setting flash[:notice] = l(:notice_successful_update) redirect_to plugin_settings_path(@plugin) else diff --git a/test/functional/settings_controller_test.rb b/test/functional/settings_controller_test.rb index c506978c0..4c1019191 100644 --- a/test/functional/settings_controller_test.rb +++ b/test/functional/settings_controller_test.rb @@ -242,6 +242,20 @@ class SettingsControllerTest < Redmine::ControllerTest assert_equal({'sample_setting' => 'Value'}, Setting.plugin_foo) end + def test_post_empty_plugin_settings + Redmine::Plugin.register(:foo) do + settings :partial => 'not blank', # so that configurable? is true + :default => {'sample_setting' => 'Plugin setting value'} + end + + post :plugin, :params => { + :id => 'foo' + } + assert_redirected_to '/settings/plugin/foo' + + assert_equal({}, Setting.plugin_foo) + end + def test_post_non_configurable_plugin_settings Redmine::Plugin.register(:foo) {} |