Commit 008e5d64 authored by jplang's avatar jplang

Don't error when posting empty plugin settings (#26393).

git-svn-id: https://svn.redmine.org/redmine/trunk@16812 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent cad3b9ca
...@@ -67,7 +67,8 @@ class SettingsController < ApplicationController ...@@ -67,7 +67,8 @@ class SettingsController < ApplicationController
end end
if request.post? 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) flash[:notice] = l(:notice_successful_update)
redirect_to plugin_settings_path(@plugin) redirect_to plugin_settings_path(@plugin)
else else
......
...@@ -242,6 +242,20 @@ class SettingsControllerTest < Redmine::ControllerTest ...@@ -242,6 +242,20 @@ class SettingsControllerTest < Redmine::ControllerTest
assert_equal({'sample_setting' => 'Value'}, Setting.plugin_foo) assert_equal({'sample_setting' => 'Value'}, Setting.plugin_foo)
end 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 def test_post_non_configurable_plugin_settings
Redmine::Plugin.register(:foo) {} Redmine::Plugin.register(:foo) {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment