Adds tests for plugin settings editing.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8039 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
8bbb5d9686
commit
fd18c51938
|
@ -51,12 +51,12 @@ class SettingsController < ApplicationController
|
||||||
def plugin
|
def plugin
|
||||||
@plugin = Redmine::Plugin.find(params[:id])
|
@plugin = Redmine::Plugin.find(params[:id])
|
||||||
if request.post?
|
if request.post?
|
||||||
Setting["plugin_#{@plugin.id}"] = params[:settings]
|
Setting.send "plugin_#{@plugin.id}=", params[:settings]
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
redirect_to :action => 'plugin', :id => @plugin.id
|
redirect_to :action => 'plugin', :id => @plugin.id
|
||||||
else
|
else
|
||||||
@partial = @plugin.settings[:partial]
|
@partial = @plugin.settings[:partial]
|
||||||
@settings = Setting["plugin_#{@plugin.id}"]
|
@settings = Setting.send "plugin_#{@plugin.id}"
|
||||||
end
|
end
|
||||||
rescue Redmine::PluginNotFound
|
rescue Redmine::PluginNotFound
|
||||||
render_404
|
render_404
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
<p><label>Example setting</label><%= text_field_tag 'settings[sample_setting]', @settings['sample_setting'] %></p>
|
|
@ -56,4 +56,33 @@ class SettingsControllerTest < ActionController::TestCase
|
||||||
assert_equal %w(issue_added issue_updated news_added), Setting.notified_events
|
assert_equal %w(issue_added issue_updated news_added), Setting.notified_events
|
||||||
assert_equal 'Test footer', Setting.emails_footer
|
assert_equal 'Test footer', Setting.emails_footer
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_get_plugin_settings
|
||||||
|
Setting.stubs(:plugin_foo).returns({'sample_setting' => 'Plugin setting value'})
|
||||||
|
ActionController::Base.view_paths.unshift(File.join(Rails.root, "test/fixtures/plugins"))
|
||||||
|
Redmine::Plugin.register :foo do
|
||||||
|
settings :partial => "foo_plugin/foo_plugin_settings"
|
||||||
|
end
|
||||||
|
|
||||||
|
get :plugin, :id => 'foo'
|
||||||
|
assert_response :success
|
||||||
|
assert_template 'plugin'
|
||||||
|
assert_tag 'form', :attributes => {:action => '/settings/plugin/foo'},
|
||||||
|
:descendant => {:tag => 'input', :attributes => {:name => 'settings[sample_setting]', :value => 'Plugin setting value'}}
|
||||||
|
|
||||||
|
Redmine::Plugin.clear
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_get_invalid_plugin_settings
|
||||||
|
get :plugin, :id => 'none'
|
||||||
|
assert_response 404
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_post_plugin_settings
|
||||||
|
Setting.expects(:plugin_foo=).with({'sample_setting' => 'Value'}).returns(true)
|
||||||
|
Redmine::Plugin.register(:foo) {}
|
||||||
|
|
||||||
|
post :plugin, :id => 'foo', :settings => {'sample_setting' => 'Value'}
|
||||||
|
assert_redirected_to '/settings/plugin/foo'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue