Mercurial > hg > soundsoftware-site
comparison .svn/pristine/e0/e0d1fbb196a28714b6ec9ca5302073a9280b09a0.svn-base @ 1494:e248c7af89ec redmine-2.4
Update to Redmine SVN revision 12979 on 2.4-stable branch
author | Chris Cannam |
---|---|
date | Mon, 17 Mar 2014 08:54:02 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1464:261b3d9a4903 | 1494:e248c7af89ec |
---|---|
1 # Redmine - project management software | |
2 # Copyright (C) 2006-2014 Jean-Philippe Lang | |
3 # | |
4 # This program is free software; you can redistribute it and/or | |
5 # modify it under the terms of the GNU General Public License | |
6 # as published by the Free Software Foundation; either version 2 | |
7 # of the License, or (at your option) any later version. | |
8 # | |
9 # This program is distributed in the hope that it will be useful, | |
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 # GNU General Public License for more details. | |
13 # | |
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 | |
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 | |
18 require File.expand_path('../../test_helper', __FILE__) | |
19 | |
20 class SettingsControllerTest < ActionController::TestCase | |
21 fixtures :users | |
22 | |
23 def setup | |
24 User.current = nil | |
25 @request.session[:user_id] = 1 # admin | |
26 end | |
27 | |
28 def test_index | |
29 get :index | |
30 assert_response :success | |
31 assert_template 'edit' | |
32 end | |
33 | |
34 def test_get_edit | |
35 get :edit | |
36 assert_response :success | |
37 assert_template 'edit' | |
38 | |
39 assert_tag 'input', :attributes => {:name => 'settings[enabled_scm][]', :value => ''} | |
40 end | |
41 | |
42 def test_get_edit_should_preselect_default_issue_list_columns | |
43 with_settings :issue_list_default_columns => %w(tracker subject status updated_on) do | |
44 get :edit | |
45 assert_response :success | |
46 end | |
47 | |
48 assert_select 'select[id=selected_columns][name=?]', 'settings[issue_list_default_columns][]' do | |
49 assert_select 'option', 4 | |
50 assert_select 'option[value=tracker]', :text => 'Tracker' | |
51 assert_select 'option[value=subject]', :text => 'Subject' | |
52 assert_select 'option[value=status]', :text => 'Status' | |
53 assert_select 'option[value=updated_on]', :text => 'Updated' | |
54 end | |
55 | |
56 assert_select 'select[id=available_columns]' do | |
57 assert_select 'option[value=tracker]', 0 | |
58 assert_select 'option[value=priority]', :text => 'Priority' | |
59 end | |
60 end | |
61 | |
62 def test_get_edit_without_trackers_should_succeed | |
63 Tracker.delete_all | |
64 | |
65 get :edit | |
66 assert_response :success | |
67 end | |
68 | |
69 def test_post_edit_notifications | |
70 post :edit, :settings => {:mail_from => 'functional@test.foo', | |
71 :bcc_recipients => '0', | |
72 :notified_events => %w(issue_added issue_updated news_added), | |
73 :emails_footer => 'Test footer' | |
74 } | |
75 assert_redirected_to '/settings' | |
76 assert_equal 'functional@test.foo', Setting.mail_from | |
77 assert !Setting.bcc_recipients? | |
78 assert_equal %w(issue_added issue_updated news_added), Setting.notified_events | |
79 assert_equal 'Test footer', Setting.emails_footer | |
80 Setting.clear_cache | |
81 end | |
82 | |
83 def test_edit_commit_update_keywords | |
84 with_settings :commit_update_keywords => [ | |
85 {"keywords" => "fixes, resolves", "status_id" => "3"}, | |
86 {"keywords" => "closes", "status_id" => "5", "done_ratio" => "100", "if_tracker_id" => "2"} | |
87 ] do | |
88 get :edit | |
89 end | |
90 assert_response :success | |
91 assert_select 'tr.commit-keywords', 2 | |
92 assert_select 'tr.commit-keywords:nth-child(1)' do | |
93 assert_select 'input[name=?][value=?]', 'settings[commit_update_keywords][keywords][]', 'fixes, resolves' | |
94 assert_select 'select[name=?]', 'settings[commit_update_keywords][status_id][]' do | |
95 assert_select 'option[value=3][selected=selected]' | |
96 end | |
97 end | |
98 assert_select 'tr.commit-keywords:nth-child(2)' do | |
99 assert_select 'input[name=?][value=?]', 'settings[commit_update_keywords][keywords][]', 'closes' | |
100 assert_select 'select[name=?]', 'settings[commit_update_keywords][status_id][]' do | |
101 assert_select 'option[value=5][selected=selected]', :text => 'Closed' | |
102 end | |
103 assert_select 'select[name=?]', 'settings[commit_update_keywords][done_ratio][]' do | |
104 assert_select 'option[value=100][selected=selected]', :text => '100 %' | |
105 end | |
106 assert_select 'select[name=?]', 'settings[commit_update_keywords][if_tracker_id][]' do | |
107 assert_select 'option[value=2][selected=selected]', :text => 'Feature request' | |
108 end | |
109 end | |
110 end | |
111 | |
112 def test_edit_without_commit_update_keywords_should_show_blank_line | |
113 with_settings :commit_update_keywords => [] do | |
114 get :edit | |
115 end | |
116 assert_response :success | |
117 assert_select 'tr.commit-keywords', 1 do | |
118 assert_select 'input[name=?]:not([value])', 'settings[commit_update_keywords][keywords][]' | |
119 end | |
120 end | |
121 | |
122 def test_post_edit_commit_update_keywords | |
123 post :edit, :settings => { | |
124 :commit_update_keywords => { | |
125 :keywords => ["resolves", "closes"], | |
126 :status_id => ["3", "5"], | |
127 :done_ratio => ["", "100"], | |
128 :if_tracker_id => ["", "2"] | |
129 } | |
130 } | |
131 assert_redirected_to '/settings' | |
132 assert_equal([ | |
133 {"keywords" => "resolves", "status_id" => "3"}, | |
134 {"keywords" => "closes", "status_id" => "5", "done_ratio" => "100", "if_tracker_id" => "2"} | |
135 ], Setting.commit_update_keywords) | |
136 end | |
137 | |
138 def test_get_plugin_settings | |
139 Setting.stubs(:plugin_foo).returns({'sample_setting' => 'Plugin setting value'}) | |
140 ActionController::Base.append_view_path(File.join(Rails.root, "test/fixtures/plugins")) | |
141 Redmine::Plugin.register :foo do | |
142 settings :partial => "foo_plugin/foo_plugin_settings" | |
143 end | |
144 | |
145 get :plugin, :id => 'foo' | |
146 assert_response :success | |
147 assert_template 'plugin' | |
148 assert_tag 'form', :attributes => {:action => '/settings/plugin/foo'}, | |
149 :descendant => {:tag => 'input', :attributes => {:name => 'settings[sample_setting]', :value => 'Plugin setting value'}} | |
150 | |
151 Redmine::Plugin.clear | |
152 end | |
153 | |
154 def test_get_invalid_plugin_settings | |
155 get :plugin, :id => 'none' | |
156 assert_response 404 | |
157 end | |
158 | |
159 def test_get_non_configurable_plugin_settings | |
160 Redmine::Plugin.register(:foo) {} | |
161 | |
162 get :plugin, :id => 'foo' | |
163 assert_response 404 | |
164 | |
165 Redmine::Plugin.clear | |
166 end | |
167 | |
168 def test_post_plugin_settings | |
169 Setting.expects(:plugin_foo=).with({'sample_setting' => 'Value'}).returns(true) | |
170 Redmine::Plugin.register(:foo) do | |
171 settings :partial => 'not blank' # so that configurable? is true | |
172 end | |
173 | |
174 post :plugin, :id => 'foo', :settings => {'sample_setting' => 'Value'} | |
175 assert_redirected_to '/settings/plugin/foo' | |
176 end | |
177 | |
178 def test_post_non_configurable_plugin_settings | |
179 Redmine::Plugin.register(:foo) {} | |
180 | |
181 post :plugin, :id => 'foo', :settings => {'sample_setting' => 'Value'} | |
182 assert_response 404 | |
183 | |
184 Redmine::Plugin.clear | |
185 end | |
186 end |