comparison test/functional/settings_controller_test.rb @ 1295:622f24f53b42 redmine-2.3

Update to Redmine SVN revision 11972 on 2.3-stable branch
author Chris Cannam
date Fri, 14 Jun 2013 09:02:21 +0100
parents 433d4f72a19b
children
comparison
equal deleted inserted replaced
1294:3e4c3460b6ca 1295:622f24f53b42
1 # Redmine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2012 Jean-Philippe Lang 2 # Copyright (C) 2006-2013 Jean-Philippe Lang
3 # 3 #
4 # This program is free software; you can redistribute it and/or 4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License 5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2 6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version. 7 # of the License, or (at your option) any later version.
14 # You should have received a copy of the GNU General Public License 14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software 15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 require File.expand_path('../../test_helper', __FILE__) 18 require File.expand_path('../../test_helper', __FILE__)
19 require 'settings_controller'
20
21 # Re-raise errors caught by the controller.
22 class SettingsController; def rescue_action(e) raise e end; end
23 19
24 class SettingsControllerTest < ActionController::TestCase 20 class SettingsControllerTest < ActionController::TestCase
25 fixtures :users 21 fixtures :users
26 22
27 def setup 23 def setup
28 @controller = SettingsController.new
29 @request = ActionController::TestRequest.new
30 @response = ActionController::TestResponse.new
31 User.current = nil 24 User.current = nil
32 @request.session[:user_id] = 1 # admin 25 @request.session[:user_id] = 1 # admin
33 end 26 end
34 27
35 def test_index 28 def test_index
77 post :edit, :settings => {:mail_from => 'functional@test.foo', 70 post :edit, :settings => {:mail_from => 'functional@test.foo',
78 :bcc_recipients => '0', 71 :bcc_recipients => '0',
79 :notified_events => %w(issue_added issue_updated news_added), 72 :notified_events => %w(issue_added issue_updated news_added),
80 :emails_footer => 'Test footer' 73 :emails_footer => 'Test footer'
81 } 74 }
82 assert_redirected_to '/settings/edit' 75 assert_redirected_to '/settings'
83 assert_equal 'functional@test.foo', Setting.mail_from 76 assert_equal 'functional@test.foo', Setting.mail_from
84 assert !Setting.bcc_recipients? 77 assert !Setting.bcc_recipients?
85 assert_equal %w(issue_added issue_updated news_added), Setting.notified_events 78 assert_equal %w(issue_added issue_updated news_added), Setting.notified_events
86 assert_equal 'Test footer', Setting.emails_footer 79 assert_equal 'Test footer', Setting.emails_footer
87 Setting.clear_cache 80 Setting.clear_cache
106 def test_get_invalid_plugin_settings 99 def test_get_invalid_plugin_settings
107 get :plugin, :id => 'none' 100 get :plugin, :id => 'none'
108 assert_response 404 101 assert_response 404
109 end 102 end
110 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
111 def test_post_plugin_settings 113 def test_post_plugin_settings
112 Setting.expects(:plugin_foo=).with({'sample_setting' => 'Value'}).returns(true) 114 Setting.expects(:plugin_foo=).with({'sample_setting' => 'Value'}).returns(true)
113 Redmine::Plugin.register(:foo) {} 115 Redmine::Plugin.register(:foo) do
116 settings :partial => 'not blank' # so that configurable? is true
117 end
114 118
115 post :plugin, :id => 'foo', :settings => {'sample_setting' => 'Value'} 119 post :plugin, :id => 'foo', :settings => {'sample_setting' => 'Value'}
116 assert_redirected_to '/settings/plugin/foo' 120 assert_redirected_to '/settings/plugin/foo'
117 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
118 end 131 end