Fix 500 error for requests to the settings path for non-configurable plugins (#12911).
Path by Harry Garrood. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11216 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
253197c598
commit
bb31402939
@ -52,6 +52,11 @@ class SettingsController < ApplicationController
|
|||||||
|
|
||||||
def plugin
|
def plugin
|
||||||
@plugin = Redmine::Plugin.find(params[:id])
|
@plugin = Redmine::Plugin.find(params[:id])
|
||||||
|
unless @plugin.configurable?
|
||||||
|
render_404
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if request.post?
|
if request.post?
|
||||||
Setting.send "plugin_#{@plugin.id}=", params[:settings]
|
Setting.send "plugin_#{@plugin.id}=", params[:settings]
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
|
@ -101,11 +101,31 @@ class SettingsControllerTest < ActionController::TestCase
|
|||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_get_non_configurable_plugin_settings
|
||||||
|
Redmine::Plugin.register(:foo) {}
|
||||||
|
|
||||||
|
get :plugin, :id => 'foo'
|
||||||
|
assert_response 404
|
||||||
|
|
||||||
|
Redmine::Plugin.clear
|
||||||
|
end
|
||||||
|
|
||||||
def test_post_plugin_settings
|
def test_post_plugin_settings
|
||||||
Setting.expects(:plugin_foo=).with({'sample_setting' => 'Value'}).returns(true)
|
Setting.expects(:plugin_foo=).with({'sample_setting' => 'Value'}).returns(true)
|
||||||
Redmine::Plugin.register(:foo) {}
|
Redmine::Plugin.register(:foo) do
|
||||||
|
settings :partial => 'not blank' # so that configurable? is true
|
||||||
|
end
|
||||||
|
|
||||||
post :plugin, :id => 'foo', :settings => {'sample_setting' => 'Value'}
|
post :plugin, :id => 'foo', :settings => {'sample_setting' => 'Value'}
|
||||||
assert_redirected_to '/settings/plugin/foo'
|
assert_redirected_to '/settings/plugin/foo'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_post_non_configurable_plugin_settings
|
||||||
|
Redmine::Plugin.register(:foo) {}
|
||||||
|
|
||||||
|
post :plugin, :id => 'foo', :settings => {'sample_setting' => 'Value'}
|
||||||
|
assert_response 404
|
||||||
|
|
||||||
|
Redmine::Plugin.clear
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user