@@ -52,6 +52,11 class SettingsController < ApplicationController | |||||
52 |
|
52 | |||
53 | def plugin |
|
53 | def plugin | |
54 | @plugin = Redmine::Plugin.find(params[:id]) |
|
54 | @plugin = Redmine::Plugin.find(params[:id]) | |
|
55 | unless @plugin.configurable? | |||
|
56 | render_404 | |||
|
57 | return | |||
|
58 | end | |||
|
59 | ||||
55 | if request.post? |
|
60 | if request.post? | |
56 | Setting.send "plugin_#{@plugin.id}=", params[:settings] |
|
61 | Setting.send "plugin_#{@plugin.id}=", params[:settings] | |
57 | flash[:notice] = l(:notice_successful_update) |
|
62 | flash[:notice] = l(:notice_successful_update) |
@@ -101,11 +101,31 class SettingsControllerTest < ActionController::TestCase | |||||
101 | assert_response 404 |
|
101 | assert_response 404 | |
102 | end |
|
102 | end | |
103 |
|
103 | |||
|
104 | def test_get_non_configurable_plugin_settings | |||
|
105 | Redmine::Plugin.register(:foo) {} | |||
|
106 | ||||
|
107 | get :plugin, :id => 'foo' | |||
|
108 | assert_response 404 | |||
|
109 | ||||
|
110 | Redmine::Plugin.clear | |||
|
111 | end | |||
|
112 | ||||
104 | def test_post_plugin_settings |
|
113 | def test_post_plugin_settings | |
105 | Setting.expects(:plugin_foo=).with({'sample_setting' => 'Value'}).returns(true) |
|
114 | Setting.expects(:plugin_foo=).with({'sample_setting' => 'Value'}).returns(true) | |
106 |
Redmine::Plugin.register(:foo) |
|
115 | Redmine::Plugin.register(:foo) do | |
|
116 | settings :partial => 'not blank' # so that configurable? is true | |||
|
117 | end | |||
107 |
|
118 | |||
108 | post :plugin, :id => 'foo', :settings => {'sample_setting' => 'Value'} |
|
119 | post :plugin, :id => 'foo', :settings => {'sample_setting' => 'Value'} | |
109 | assert_redirected_to '/settings/plugin/foo' |
|
120 | assert_redirected_to '/settings/plugin/foo' | |
110 | end |
|
121 | end | |
|
122 | ||||
|
123 | def test_post_non_configurable_plugin_settings | |||
|
124 | Redmine::Plugin.register(:foo) {} | |||
|
125 | ||||
|
126 | post :plugin, :id => 'foo', :settings => {'sample_setting' => 'Value'} | |||
|
127 | assert_response 404 | |||
|
128 | ||||
|
129 | Redmine::Plugin.clear | |||
|
130 | end | |||
111 | end |
|
131 | end |
General Comments 0
You need to be logged in to leave comments.
Login now