@@ -1,609 +1,609 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2014 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2014 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. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
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 |
|
19 | |||
20 | class ProjectsControllerTest < ActionController::TestCase |
|
20 | class ProjectsControllerTest < ActionController::TestCase | |
21 | fixtures :projects, :versions, :users, :roles, :members, |
|
21 | fixtures :projects, :versions, :users, :roles, :members, | |
22 | :member_roles, :issues, :journals, :journal_details, |
|
22 | :member_roles, :issues, :journals, :journal_details, | |
23 | :trackers, :projects_trackers, :issue_statuses, |
|
23 | :trackers, :projects_trackers, :issue_statuses, | |
24 | :enabled_modules, :enumerations, :boards, :messages, |
|
24 | :enabled_modules, :enumerations, :boards, :messages, | |
25 | :attachments, :custom_fields, :custom_values, :time_entries |
|
25 | :attachments, :custom_fields, :custom_values, :time_entries | |
26 |
|
26 | |||
27 | def setup |
|
27 | def setup | |
28 | @request.session[:user_id] = nil |
|
28 | @request.session[:user_id] = nil | |
29 | Setting.default_language = 'en' |
|
29 | Setting.default_language = 'en' | |
30 | end |
|
30 | end | |
31 |
|
31 | |||
32 | def test_index_by_anonymous_should_not_show_private_projects |
|
32 | def test_index_by_anonymous_should_not_show_private_projects | |
33 | get :index |
|
33 | get :index | |
34 | assert_response :success |
|
34 | assert_response :success | |
35 | assert_template 'index' |
|
35 | assert_template 'index' | |
36 | projects = assigns(:projects) |
|
36 | projects = assigns(:projects) | |
37 | assert_not_nil projects |
|
37 | assert_not_nil projects | |
38 | assert projects.all?(&:is_public?) |
|
38 | assert projects.all?(&:is_public?) | |
39 |
|
39 | |||
40 | assert_select 'ul' do |
|
40 | assert_select 'ul' do | |
41 | assert_select 'li' do |
|
41 | assert_select 'li' do | |
42 | assert_select 'a', :text => 'eCookbook' |
|
42 | assert_select 'a', :text => 'eCookbook' | |
43 | assert_select 'ul' do |
|
43 | assert_select 'ul' do | |
44 | assert_select 'a', :text => 'Child of private child' |
|
44 | assert_select 'a', :text => 'Child of private child' | |
45 | end |
|
45 | end | |
46 | end |
|
46 | end | |
47 | end |
|
47 | end | |
48 | assert_select 'a', :text => /Private child of eCookbook/, :count => 0 |
|
48 | assert_select 'a', :text => /Private child of eCookbook/, :count => 0 | |
49 | end |
|
49 | end | |
50 |
|
50 | |||
51 | def test_index_atom |
|
51 | def test_index_atom | |
52 | get :index, :format => 'atom' |
|
52 | get :index, :format => 'atom' | |
53 | assert_response :success |
|
53 | assert_response :success | |
54 | assert_template 'common/feed' |
|
54 | assert_template 'common/feed' | |
55 | assert_select 'feed>title', :text => 'Redmine: Latest projects' |
|
55 | assert_select 'feed>title', :text => 'Redmine: Latest projects' | |
56 | assert_select 'feed>entry', :count => Project.visible(User.current).count |
|
56 | assert_select 'feed>entry', :count => Project.visible(User.current).count | |
57 | end |
|
57 | end | |
58 |
|
58 | |||
59 | test "#index by non-admin user with view_time_entries permission should show overall spent time link" do |
|
59 | test "#index by non-admin user with view_time_entries permission should show overall spent time link" do | |
60 | @request.session[:user_id] = 3 |
|
60 | @request.session[:user_id] = 3 | |
61 | get :index |
|
61 | get :index | |
62 | assert_template 'index' |
|
62 | assert_template 'index' | |
63 | assert_select 'a[href=?]', '/time_entries' |
|
63 | assert_select 'a[href=?]', '/time_entries' | |
64 | end |
|
64 | end | |
65 |
|
65 | |||
66 | test "#index by non-admin user without view_time_entries permission should not show overall spent time link" do |
|
66 | test "#index by non-admin user without view_time_entries permission should not show overall spent time link" do | |
67 | Role.find(2).remove_permission! :view_time_entries |
|
67 | Role.find(2).remove_permission! :view_time_entries | |
68 | Role.non_member.remove_permission! :view_time_entries |
|
68 | Role.non_member.remove_permission! :view_time_entries | |
69 | Role.anonymous.remove_permission! :view_time_entries |
|
69 | Role.anonymous.remove_permission! :view_time_entries | |
70 | @request.session[:user_id] = 3 |
|
70 | @request.session[:user_id] = 3 | |
71 |
|
71 | |||
72 | get :index |
|
72 | get :index | |
73 | assert_template 'index' |
|
73 | assert_template 'index' | |
74 | assert_select 'a[href=?]', '/time_entries', 0 |
|
74 | assert_select 'a[href=?]', '/time_entries', 0 | |
75 | end |
|
75 | end | |
76 |
|
76 | |||
77 | test "#new by admin user should accept get" do |
|
77 | test "#new by admin user should accept get" do | |
78 | @request.session[:user_id] = 1 |
|
78 | @request.session[:user_id] = 1 | |
79 |
|
79 | |||
80 | get :new |
|
80 | get :new | |
81 | assert_response :success |
|
81 | assert_response :success | |
82 | assert_template 'new' |
|
82 | assert_template 'new' | |
83 | end |
|
83 | end | |
84 |
|
84 | |||
85 | test "#new by non-admin user with add_project permission should accept get" do |
|
85 | test "#new by non-admin user with add_project permission should accept get" do | |
86 | Role.non_member.add_permission! :add_project |
|
86 | Role.non_member.add_permission! :add_project | |
87 | @request.session[:user_id] = 9 |
|
87 | @request.session[:user_id] = 9 | |
88 |
|
88 | |||
89 | get :new |
|
89 | get :new | |
90 | assert_response :success |
|
90 | assert_response :success | |
91 | assert_template 'new' |
|
91 | assert_template 'new' | |
92 | assert_select 'select[name=?]', 'project[parent_id]', 0 |
|
92 | assert_select 'select[name=?]', 'project[parent_id]', 0 | |
93 | end |
|
93 | end | |
94 |
|
94 | |||
95 | test "#new by non-admin user with add_subprojects permission should accept get" do |
|
95 | test "#new by non-admin user with add_subprojects permission should accept get" do | |
96 | Role.find(1).remove_permission! :add_project |
|
96 | Role.find(1).remove_permission! :add_project | |
97 | Role.find(1).add_permission! :add_subprojects |
|
97 | Role.find(1).add_permission! :add_subprojects | |
98 | @request.session[:user_id] = 2 |
|
98 | @request.session[:user_id] = 2 | |
99 |
|
99 | |||
100 | get :new, :parent_id => 'ecookbook' |
|
100 | get :new, :parent_id => 'ecookbook' | |
101 | assert_response :success |
|
101 | assert_response :success | |
102 | assert_template 'new' |
|
102 | assert_template 'new' | |
103 |
|
103 | |||
104 | assert_select 'select[name=?]', 'project[parent_id]' do |
|
104 | assert_select 'select[name=?]', 'project[parent_id]' do | |
105 | # parent project selected |
|
105 | # parent project selected | |
106 | assert_select 'option[value=1][selected=selected]' |
|
106 | assert_select 'option[value=1][selected=selected]' | |
107 | # no empty value |
|
107 | # no empty value | |
108 | assert_select 'option[value=]', 0 |
|
108 | assert_select 'option[value=]', 0 | |
109 | end |
|
109 | end | |
110 | end |
|
110 | end | |
111 |
|
111 | |||
112 | test "#create by admin user should create a new project" do |
|
112 | test "#create by admin user should create a new project" do | |
113 | @request.session[:user_id] = 1 |
|
113 | @request.session[:user_id] = 1 | |
114 |
|
114 | |||
115 | post :create, |
|
115 | post :create, | |
116 | :project => { |
|
116 | :project => { | |
117 | :name => "blog", |
|
117 | :name => "blog", | |
118 | :description => "weblog", |
|
118 | :description => "weblog", | |
119 | :homepage => 'http://weblog', |
|
119 | :homepage => 'http://weblog', | |
120 | :identifier => "blog", |
|
120 | :identifier => "blog", | |
121 | :is_public => 1, |
|
121 | :is_public => 1, | |
122 | :custom_field_values => { '3' => 'Beta' }, |
|
122 | :custom_field_values => { '3' => 'Beta' }, | |
123 | :tracker_ids => ['1', '3'], |
|
123 | :tracker_ids => ['1', '3'], | |
124 | # an issue custom field that is not for all project |
|
124 | # an issue custom field that is not for all project | |
125 | :issue_custom_field_ids => ['9'], |
|
125 | :issue_custom_field_ids => ['9'], | |
126 | :enabled_module_names => ['issue_tracking', 'news', 'repository'] |
|
126 | :enabled_module_names => ['issue_tracking', 'news', 'repository'] | |
127 | } |
|
127 | } | |
128 | assert_redirected_to '/projects/blog/settings' |
|
128 | assert_redirected_to '/projects/blog/settings' | |
129 |
|
129 | |||
130 | project = Project.find_by_name('blog') |
|
130 | project = Project.find_by_name('blog') | |
131 | assert_kind_of Project, project |
|
131 | assert_kind_of Project, project | |
132 | assert project.active? |
|
132 | assert project.active? | |
133 | assert_equal 'weblog', project.description |
|
133 | assert_equal 'weblog', project.description | |
134 | assert_equal 'http://weblog', project.homepage |
|
134 | assert_equal 'http://weblog', project.homepage | |
135 | assert_equal true, project.is_public? |
|
135 | assert_equal true, project.is_public? | |
136 | assert_nil project.parent |
|
136 | assert_nil project.parent | |
137 | assert_equal 'Beta', project.custom_value_for(3).value |
|
137 | assert_equal 'Beta', project.custom_value_for(3).value | |
138 | assert_equal [1, 3], project.trackers.map(&:id).sort |
|
138 | assert_equal [1, 3], project.trackers.map(&:id).sort | |
139 | assert_equal ['issue_tracking', 'news', 'repository'], project.enabled_module_names.sort |
|
139 | assert_equal ['issue_tracking', 'news', 'repository'], project.enabled_module_names.sort | |
140 | assert project.issue_custom_fields.include?(IssueCustomField.find(9)) |
|
140 | assert project.issue_custom_fields.include?(IssueCustomField.find(9)) | |
141 | end |
|
141 | end | |
142 |
|
142 | |||
143 | test "#create by admin user should create a new subproject" do |
|
143 | test "#create by admin user should create a new subproject" do | |
144 | @request.session[:user_id] = 1 |
|
144 | @request.session[:user_id] = 1 | |
145 |
|
145 | |||
146 | assert_difference 'Project.count' do |
|
146 | assert_difference 'Project.count' do | |
147 | post :create, :project => { :name => "blog", |
|
147 | post :create, :project => { :name => "blog", | |
148 | :description => "weblog", |
|
148 | :description => "weblog", | |
149 | :identifier => "blog", |
|
149 | :identifier => "blog", | |
150 | :is_public => 1, |
|
150 | :is_public => 1, | |
151 | :custom_field_values => { '3' => 'Beta' }, |
|
151 | :custom_field_values => { '3' => 'Beta' }, | |
152 | :parent_id => 1 |
|
152 | :parent_id => 1 | |
153 | } |
|
153 | } | |
154 | assert_redirected_to '/projects/blog/settings' |
|
154 | assert_redirected_to '/projects/blog/settings' | |
155 | end |
|
155 | end | |
156 |
|
156 | |||
157 | project = Project.find_by_name('blog') |
|
157 | project = Project.find_by_name('blog') | |
158 | assert_kind_of Project, project |
|
158 | assert_kind_of Project, project | |
159 | assert_equal Project.find(1), project.parent |
|
159 | assert_equal Project.find(1), project.parent | |
160 | end |
|
160 | end | |
161 |
|
161 | |||
162 | test "#create by admin user should continue" do |
|
162 | test "#create by admin user should continue" do | |
163 | @request.session[:user_id] = 1 |
|
163 | @request.session[:user_id] = 1 | |
164 |
|
164 | |||
165 | assert_difference 'Project.count' do |
|
165 | assert_difference 'Project.count' do | |
166 | post :create, :project => {:name => "blog", :identifier => "blog"}, :continue => 'Create and continue' |
|
166 | post :create, :project => {:name => "blog", :identifier => "blog"}, :continue => 'Create and continue' | |
167 | end |
|
167 | end | |
168 | assert_redirected_to '/projects/new' |
|
168 | assert_redirected_to '/projects/new' | |
169 | end |
|
169 | end | |
170 |
|
170 | |||
171 | test "#create by non-admin user with add_project permission should create a new project" do |
|
171 | test "#create by non-admin user with add_project permission should create a new project" do | |
172 | Role.non_member.add_permission! :add_project |
|
172 | Role.non_member.add_permission! :add_project | |
173 | @request.session[:user_id] = 9 |
|
173 | @request.session[:user_id] = 9 | |
174 |
|
174 | |||
175 | post :create, :project => { :name => "blog", |
|
175 | post :create, :project => { :name => "blog", | |
176 | :description => "weblog", |
|
176 | :description => "weblog", | |
177 | :identifier => "blog", |
|
177 | :identifier => "blog", | |
178 | :is_public => 1, |
|
178 | :is_public => 1, | |
179 | :custom_field_values => { '3' => 'Beta' }, |
|
179 | :custom_field_values => { '3' => 'Beta' }, | |
180 | :tracker_ids => ['1', '3'], |
|
180 | :tracker_ids => ['1', '3'], | |
181 | :enabled_module_names => ['issue_tracking', 'news', 'repository'] |
|
181 | :enabled_module_names => ['issue_tracking', 'news', 'repository'] | |
182 | } |
|
182 | } | |
183 |
|
183 | |||
184 | assert_redirected_to '/projects/blog/settings' |
|
184 | assert_redirected_to '/projects/blog/settings' | |
185 |
|
185 | |||
186 | project = Project.find_by_name('blog') |
|
186 | project = Project.find_by_name('blog') | |
187 | assert_kind_of Project, project |
|
187 | assert_kind_of Project, project | |
188 | assert_equal 'weblog', project.description |
|
188 | assert_equal 'weblog', project.description | |
189 | assert_equal true, project.is_public? |
|
189 | assert_equal true, project.is_public? | |
190 | assert_equal [1, 3], project.trackers.map(&:id).sort |
|
190 | assert_equal [1, 3], project.trackers.map(&:id).sort | |
191 | assert_equal ['issue_tracking', 'news', 'repository'], project.enabled_module_names.sort |
|
191 | assert_equal ['issue_tracking', 'news', 'repository'], project.enabled_module_names.sort | |
192 |
|
192 | |||
193 | # User should be added as a project member |
|
193 | # User should be added as a project member | |
194 | assert User.find(9).member_of?(project) |
|
194 | assert User.find(9).member_of?(project) | |
195 | assert_equal 1, project.members.size |
|
195 | assert_equal 1, project.members.size | |
196 | end |
|
196 | end | |
197 |
|
197 | |||
198 | test "#create by non-admin user with add_project permission should fail with parent_id" do |
|
198 | test "#create by non-admin user with add_project permission should fail with parent_id" do | |
199 | Role.non_member.add_permission! :add_project |
|
199 | Role.non_member.add_permission! :add_project | |
200 | @request.session[:user_id] = 9 |
|
200 | @request.session[:user_id] = 9 | |
201 |
|
201 | |||
202 | assert_no_difference 'Project.count' do |
|
202 | assert_no_difference 'Project.count' do | |
203 | post :create, :project => { :name => "blog", |
|
203 | post :create, :project => { :name => "blog", | |
204 | :description => "weblog", |
|
204 | :description => "weblog", | |
205 | :identifier => "blog", |
|
205 | :identifier => "blog", | |
206 | :is_public => 1, |
|
206 | :is_public => 1, | |
207 | :custom_field_values => { '3' => 'Beta' }, |
|
207 | :custom_field_values => { '3' => 'Beta' }, | |
208 | :parent_id => 1 |
|
208 | :parent_id => 1 | |
209 | } |
|
209 | } | |
210 | end |
|
210 | end | |
211 | assert_response :success |
|
211 | assert_response :success | |
212 | project = assigns(:project) |
|
212 | project = assigns(:project) | |
213 | assert_kind_of Project, project |
|
213 | assert_kind_of Project, project | |
214 | assert_not_equal [], project.errors[:parent_id] |
|
214 | assert_not_equal [], project.errors[:parent_id] | |
215 | end |
|
215 | end | |
216 |
|
216 | |||
217 | test "#create by non-admin user with add_subprojects permission should create a project with a parent_id" do |
|
217 | test "#create by non-admin user with add_subprojects permission should create a project with a parent_id" do | |
218 | Role.find(1).remove_permission! :add_project |
|
218 | Role.find(1).remove_permission! :add_project | |
219 | Role.find(1).add_permission! :add_subprojects |
|
219 | Role.find(1).add_permission! :add_subprojects | |
220 | @request.session[:user_id] = 2 |
|
220 | @request.session[:user_id] = 2 | |
221 |
|
221 | |||
222 | post :create, :project => { :name => "blog", |
|
222 | post :create, :project => { :name => "blog", | |
223 | :description => "weblog", |
|
223 | :description => "weblog", | |
224 | :identifier => "blog", |
|
224 | :identifier => "blog", | |
225 | :is_public => 1, |
|
225 | :is_public => 1, | |
226 | :custom_field_values => { '3' => 'Beta' }, |
|
226 | :custom_field_values => { '3' => 'Beta' }, | |
227 | :parent_id => 1 |
|
227 | :parent_id => 1 | |
228 | } |
|
228 | } | |
229 | assert_redirected_to '/projects/blog/settings' |
|
229 | assert_redirected_to '/projects/blog/settings' | |
230 | project = Project.find_by_name('blog') |
|
230 | project = Project.find_by_name('blog') | |
231 | end |
|
231 | end | |
232 |
|
232 | |||
233 | test "#create by non-admin user with add_subprojects permission should fail without parent_id" do |
|
233 | test "#create by non-admin user with add_subprojects permission should fail without parent_id" do | |
234 | Role.find(1).remove_permission! :add_project |
|
234 | Role.find(1).remove_permission! :add_project | |
235 | Role.find(1).add_permission! :add_subprojects |
|
235 | Role.find(1).add_permission! :add_subprojects | |
236 | @request.session[:user_id] = 2 |
|
236 | @request.session[:user_id] = 2 | |
237 |
|
237 | |||
238 | assert_no_difference 'Project.count' do |
|
238 | assert_no_difference 'Project.count' do | |
239 | post :create, :project => { :name => "blog", |
|
239 | post :create, :project => { :name => "blog", | |
240 | :description => "weblog", |
|
240 | :description => "weblog", | |
241 | :identifier => "blog", |
|
241 | :identifier => "blog", | |
242 | :is_public => 1, |
|
242 | :is_public => 1, | |
243 | :custom_field_values => { '3' => 'Beta' } |
|
243 | :custom_field_values => { '3' => 'Beta' } | |
244 | } |
|
244 | } | |
245 | end |
|
245 | end | |
246 | assert_response :success |
|
246 | assert_response :success | |
247 | project = assigns(:project) |
|
247 | project = assigns(:project) | |
248 | assert_kind_of Project, project |
|
248 | assert_kind_of Project, project | |
249 | assert_not_equal [], project.errors[:parent_id] |
|
249 | assert_not_equal [], project.errors[:parent_id] | |
250 | end |
|
250 | end | |
251 |
|
251 | |||
252 | test "#create by non-admin user with add_subprojects permission should fail with unauthorized parent_id" do |
|
252 | test "#create by non-admin user with add_subprojects permission should fail with unauthorized parent_id" do | |
253 | Role.find(1).remove_permission! :add_project |
|
253 | Role.find(1).remove_permission! :add_project | |
254 | Role.find(1).add_permission! :add_subprojects |
|
254 | Role.find(1).add_permission! :add_subprojects | |
255 | @request.session[:user_id] = 2 |
|
255 | @request.session[:user_id] = 2 | |
256 |
|
256 | |||
257 | assert !User.find(2).member_of?(Project.find(6)) |
|
257 | assert !User.find(2).member_of?(Project.find(6)) | |
258 | assert_no_difference 'Project.count' do |
|
258 | assert_no_difference 'Project.count' do | |
259 | post :create, :project => { :name => "blog", |
|
259 | post :create, :project => { :name => "blog", | |
260 | :description => "weblog", |
|
260 | :description => "weblog", | |
261 | :identifier => "blog", |
|
261 | :identifier => "blog", | |
262 | :is_public => 1, |
|
262 | :is_public => 1, | |
263 | :custom_field_values => { '3' => 'Beta' }, |
|
263 | :custom_field_values => { '3' => 'Beta' }, | |
264 | :parent_id => 6 |
|
264 | :parent_id => 6 | |
265 | } |
|
265 | } | |
266 | end |
|
266 | end | |
267 | assert_response :success |
|
267 | assert_response :success | |
268 | project = assigns(:project) |
|
268 | project = assigns(:project) | |
269 | assert_kind_of Project, project |
|
269 | assert_kind_of Project, project | |
270 | assert_not_equal [], project.errors[:parent_id] |
|
270 | assert_not_equal [], project.errors[:parent_id] | |
271 | end |
|
271 | end | |
272 |
|
272 | |||
273 | def test_create_subproject_with_inherit_members_should_inherit_members |
|
273 | def test_create_subproject_with_inherit_members_should_inherit_members | |
274 | Role.find_by_name('Manager').add_permission! :add_subprojects |
|
274 | Role.find_by_name('Manager').add_permission! :add_subprojects | |
275 | parent = Project.find(1) |
|
275 | parent = Project.find(1) | |
276 | @request.session[:user_id] = 2 |
|
276 | @request.session[:user_id] = 2 | |
277 |
|
277 | |||
278 | assert_difference 'Project.count' do |
|
278 | assert_difference 'Project.count' do | |
279 | post :create, :project => { |
|
279 | post :create, :project => { | |
280 | :name => 'inherited', :identifier => 'inherited', :parent_id => parent.id, :inherit_members => '1' |
|
280 | :name => 'inherited', :identifier => 'inherited', :parent_id => parent.id, :inherit_members => '1' | |
281 | } |
|
281 | } | |
282 | assert_response 302 |
|
282 | assert_response 302 | |
283 | end |
|
283 | end | |
284 |
|
284 | |||
285 | project = Project.order('id desc').first |
|
285 | project = Project.order('id desc').first | |
286 | assert_equal 'inherited', project.name |
|
286 | assert_equal 'inherited', project.name | |
287 | assert_equal parent, project.parent |
|
287 | assert_equal parent, project.parent | |
288 | assert project.memberships.count > 0 |
|
288 | assert project.memberships.count > 0 | |
289 | assert_equal parent.memberships.count, project.memberships.count |
|
289 | assert_equal parent.memberships.count, project.memberships.count | |
290 | end |
|
290 | end | |
291 |
|
291 | |||
292 | def test_create_should_preserve_modules_on_validation_failure |
|
292 | def test_create_should_preserve_modules_on_validation_failure | |
293 | with_settings :default_projects_modules => ['issue_tracking', 'repository'] do |
|
293 | with_settings :default_projects_modules => ['issue_tracking', 'repository'] do | |
294 | @request.session[:user_id] = 1 |
|
294 | @request.session[:user_id] = 1 | |
295 | assert_no_difference 'Project.count' do |
|
295 | assert_no_difference 'Project.count' do | |
296 | post :create, :project => { |
|
296 | post :create, :project => { | |
297 | :name => "blog", |
|
297 | :name => "blog", | |
298 | :identifier => "", |
|
298 | :identifier => "", | |
299 | :enabled_module_names => %w(issue_tracking news) |
|
299 | :enabled_module_names => %w(issue_tracking news) | |
300 | } |
|
300 | } | |
301 | end |
|
301 | end | |
302 | assert_response :success |
|
302 | assert_response :success | |
303 | project = assigns(:project) |
|
303 | project = assigns(:project) | |
304 | assert_equal %w(issue_tracking news), project.enabled_module_names.sort |
|
304 | assert_equal %w(issue_tracking news), project.enabled_module_names.sort | |
305 | end |
|
305 | end | |
306 | end |
|
306 | end | |
307 |
|
307 | |||
308 | def test_show_by_id |
|
308 | def test_show_by_id | |
309 | get :show, :id => 1 |
|
309 | get :show, :id => 1 | |
310 | assert_response :success |
|
310 | assert_response :success | |
311 | assert_template 'show' |
|
311 | assert_template 'show' | |
312 | assert_not_nil assigns(:project) |
|
312 | assert_not_nil assigns(:project) | |
313 | end |
|
313 | end | |
314 |
|
314 | |||
315 | def test_show_by_identifier |
|
315 | def test_show_by_identifier | |
316 | get :show, :id => 'ecookbook' |
|
316 | get :show, :id => 'ecookbook' | |
317 | assert_response :success |
|
317 | assert_response :success | |
318 | assert_template 'show' |
|
318 | assert_template 'show' | |
319 | assert_not_nil assigns(:project) |
|
319 | assert_not_nil assigns(:project) | |
320 | assert_equal Project.find_by_identifier('ecookbook'), assigns(:project) |
|
320 | assert_equal Project.find_by_identifier('ecookbook'), assigns(:project) | |
321 |
|
321 | |||
322 | assert_select 'li', :text => /Development status/ |
|
322 | assert_select 'li', :text => /Development status/ | |
323 | end |
|
323 | end | |
324 |
|
324 | |||
325 | def test_show_should_not_display_empty_sidebar |
|
325 | def test_show_should_not_display_empty_sidebar | |
326 | p = Project.find(1) |
|
326 | p = Project.find(1) | |
327 | p.enabled_module_names = [] |
|
327 | p.enabled_module_names = [] | |
328 | p.save! |
|
328 | p.save! | |
329 |
|
329 | |||
330 | get :show, :id => 'ecookbook' |
|
330 | get :show, :id => 'ecookbook' | |
331 | assert_response :success |
|
331 | assert_response :success | |
332 | assert_select '#main.nosidebar' |
|
332 | assert_select '#main.nosidebar' | |
333 | end |
|
333 | end | |
334 |
|
334 | |||
335 | def test_show_should_not_display_hidden_custom_fields |
|
335 | def test_show_should_not_display_hidden_custom_fields | |
336 | ProjectCustomField.find_by_name('Development status').update_attribute :visible, false |
|
336 | ProjectCustomField.find_by_name('Development status').update_attribute :visible, false | |
337 | get :show, :id => 'ecookbook' |
|
337 | get :show, :id => 'ecookbook' | |
338 | assert_response :success |
|
338 | assert_response :success | |
339 | assert_template 'show' |
|
339 | assert_template 'show' | |
340 | assert_not_nil assigns(:project) |
|
340 | assert_not_nil assigns(:project) | |
341 |
|
341 | |||
342 | assert_select 'li', :text => /Development status/, :count => 0 |
|
342 | assert_select 'li', :text => /Development status/, :count => 0 | |
343 | end |
|
343 | end | |
344 |
|
344 | |||
345 | def test_show_should_not_fail_when_custom_values_are_nil |
|
345 | def test_show_should_not_fail_when_custom_values_are_nil | |
346 | project = Project.find_by_identifier('ecookbook') |
|
346 | project = Project.find_by_identifier('ecookbook') | |
347 | project.custom_values.first.update_attribute(:value, nil) |
|
347 | project.custom_values.first.update_attribute(:value, nil) | |
348 | get :show, :id => 'ecookbook' |
|
348 | get :show, :id => 'ecookbook' | |
349 | assert_response :success |
|
349 | assert_response :success | |
350 | assert_template 'show' |
|
350 | assert_template 'show' | |
351 | assert_not_nil assigns(:project) |
|
351 | assert_not_nil assigns(:project) | |
352 | assert_equal Project.find_by_identifier('ecookbook'), assigns(:project) |
|
352 | assert_equal Project.find_by_identifier('ecookbook'), assigns(:project) | |
353 | end |
|
353 | end | |
354 |
|
354 | |||
355 | def show_archived_project_should_be_denied |
|
355 | def show_archived_project_should_be_denied | |
356 | project = Project.find_by_identifier('ecookbook') |
|
356 | project = Project.find_by_identifier('ecookbook') | |
357 | project.archive! |
|
357 | project.archive! | |
358 |
|
358 | |||
359 | get :show, :id => 'ecookbook' |
|
359 | get :show, :id => 'ecookbook' | |
360 | assert_response 403 |
|
360 | assert_response 403 | |
361 | assert_nil assigns(:project) |
|
361 | assert_nil assigns(:project) | |
362 | assert_select 'p', :text => /archived/ |
|
362 | assert_select 'p', :text => /archived/ | |
363 | end |
|
363 | end | |
364 |
|
364 | |||
365 | def test_show_should_not_show_private_subprojects_that_are_not_visible |
|
365 | def test_show_should_not_show_private_subprojects_that_are_not_visible | |
366 | get :show, :id => 'ecookbook' |
|
366 | get :show, :id => 'ecookbook' | |
367 | assert_response :success |
|
367 | assert_response :success | |
368 | assert_template 'show' |
|
368 | assert_template 'show' | |
369 | assert_select 'a', :text => /Private child/, :count => 0 |
|
369 | assert_select 'a', :text => /Private child/, :count => 0 | |
370 | end |
|
370 | end | |
371 |
|
371 | |||
372 | def test_show_should_show_private_subprojects_that_are_visible |
|
372 | def test_show_should_show_private_subprojects_that_are_visible | |
373 | @request.session[:user_id] = 2 # manager who is a member of the private subproject |
|
373 | @request.session[:user_id] = 2 # manager who is a member of the private subproject | |
374 | get :show, :id => 'ecookbook' |
|
374 | get :show, :id => 'ecookbook' | |
375 | assert_response :success |
|
375 | assert_response :success | |
376 | assert_template 'show' |
|
376 | assert_template 'show' | |
377 | assert_select 'a', :text => /Private child/ |
|
377 | assert_select 'a', :text => /Private child/ | |
378 | end |
|
378 | end | |
379 |
|
379 | |||
380 | def test_settings |
|
380 | def test_settings | |
381 | @request.session[:user_id] = 2 # manager |
|
381 | @request.session[:user_id] = 2 # manager | |
382 | get :settings, :id => 1 |
|
382 | get :settings, :id => 1 | |
383 | assert_response :success |
|
383 | assert_response :success | |
384 | assert_template 'settings' |
|
384 | assert_template 'settings' | |
385 | end |
|
385 | end | |
386 |
|
386 | |||
387 | def test_settings_of_subproject |
|
387 | def test_settings_of_subproject | |
388 | @request.session[:user_id] = 2 |
|
388 | @request.session[:user_id] = 2 | |
389 | get :settings, :id => 'private-child' |
|
389 | get :settings, :id => 'private-child' | |
390 | assert_response :success |
|
390 | assert_response :success | |
391 | assert_template 'settings' |
|
391 | assert_template 'settings' | |
392 |
|
392 | |||
393 | assert_select 'input[type=checkbox][name=?]', 'project[inherit_members]' |
|
393 | assert_select 'input[type=checkbox][name=?]', 'project[inherit_members]' | |
394 | end |
|
394 | end | |
395 |
|
395 | |||
396 | def test_settings_should_be_denied_for_member_on_closed_project |
|
396 | def test_settings_should_be_denied_for_member_on_closed_project | |
397 | Project.find(1).close |
|
397 | Project.find(1).close | |
398 | @request.session[:user_id] = 2 # manager |
|
398 | @request.session[:user_id] = 2 # manager | |
399 |
|
399 | |||
400 | get :settings, :id => 1 |
|
400 | get :settings, :id => 1 | |
401 | assert_response 403 |
|
401 | assert_response 403 | |
402 | end |
|
402 | end | |
403 |
|
403 | |||
404 | def test_settings_should_be_denied_for_anonymous_on_closed_project |
|
404 | def test_settings_should_be_denied_for_anonymous_on_closed_project | |
405 | Project.find(1).close |
|
405 | Project.find(1).close | |
406 |
|
406 | |||
407 | get :settings, :id => 1 |
|
407 | get :settings, :id => 1 | |
408 | assert_response 302 |
|
408 | assert_response 302 | |
409 | end |
|
409 | end | |
410 |
|
410 | |||
411 | def test_update |
|
411 | def test_update | |
412 | @request.session[:user_id] = 2 # manager |
|
412 | @request.session[:user_id] = 2 # manager | |
413 | post :update, :id => 1, :project => {:name => 'Test changed name', |
|
413 | post :update, :id => 1, :project => {:name => 'Test changed name', | |
414 | :issue_custom_field_ids => ['']} |
|
414 | :issue_custom_field_ids => ['']} | |
415 | assert_redirected_to '/projects/ecookbook/settings' |
|
415 | assert_redirected_to '/projects/ecookbook/settings' | |
416 | project = Project.find(1) |
|
416 | project = Project.find(1) | |
417 | assert_equal 'Test changed name', project.name |
|
417 | assert_equal 'Test changed name', project.name | |
418 | end |
|
418 | end | |
419 |
|
419 | |||
420 | def test_update_with_failure |
|
420 | def test_update_with_failure | |
421 | @request.session[:user_id] = 2 # manager |
|
421 | @request.session[:user_id] = 2 # manager | |
422 | post :update, :id => 1, :project => {:name => ''} |
|
422 | post :update, :id => 1, :project => {:name => ''} | |
423 | assert_response :success |
|
423 | assert_response :success | |
424 | assert_template 'settings' |
|
424 | assert_template 'settings' | |
425 |
assert_error_tag :content => /name |
|
425 | assert_error_tag :content => /name #{ESCAPED_CANT} be blank/i | |
426 | end |
|
426 | end | |
427 |
|
427 | |||
428 | def test_update_should_be_denied_for_member_on_closed_project |
|
428 | def test_update_should_be_denied_for_member_on_closed_project | |
429 | Project.find(1).close |
|
429 | Project.find(1).close | |
430 | @request.session[:user_id] = 2 # manager |
|
430 | @request.session[:user_id] = 2 # manager | |
431 |
|
431 | |||
432 | post :update, :id => 1, :project => {:name => 'Closed'} |
|
432 | post :update, :id => 1, :project => {:name => 'Closed'} | |
433 | assert_response 403 |
|
433 | assert_response 403 | |
434 | assert_equal 'eCookbook', Project.find(1).name |
|
434 | assert_equal 'eCookbook', Project.find(1).name | |
435 | end |
|
435 | end | |
436 |
|
436 | |||
437 | def test_update_should_be_denied_for_anonymous_on_closed_project |
|
437 | def test_update_should_be_denied_for_anonymous_on_closed_project | |
438 | Project.find(1).close |
|
438 | Project.find(1).close | |
439 |
|
439 | |||
440 | post :update, :id => 1, :project => {:name => 'Closed'} |
|
440 | post :update, :id => 1, :project => {:name => 'Closed'} | |
441 | assert_response 302 |
|
441 | assert_response 302 | |
442 | assert_equal 'eCookbook', Project.find(1).name |
|
442 | assert_equal 'eCookbook', Project.find(1).name | |
443 | end |
|
443 | end | |
444 |
|
444 | |||
445 | def test_modules |
|
445 | def test_modules | |
446 | @request.session[:user_id] = 2 |
|
446 | @request.session[:user_id] = 2 | |
447 | Project.find(1).enabled_module_names = ['issue_tracking', 'news'] |
|
447 | Project.find(1).enabled_module_names = ['issue_tracking', 'news'] | |
448 |
|
448 | |||
449 | post :modules, :id => 1, :enabled_module_names => ['issue_tracking', 'repository', 'documents'] |
|
449 | post :modules, :id => 1, :enabled_module_names => ['issue_tracking', 'repository', 'documents'] | |
450 | assert_redirected_to '/projects/ecookbook/settings/modules' |
|
450 | assert_redirected_to '/projects/ecookbook/settings/modules' | |
451 | assert_equal ['documents', 'issue_tracking', 'repository'], Project.find(1).enabled_module_names.sort |
|
451 | assert_equal ['documents', 'issue_tracking', 'repository'], Project.find(1).enabled_module_names.sort | |
452 | end |
|
452 | end | |
453 |
|
453 | |||
454 | def test_destroy_leaf_project_without_confirmation_should_show_confirmation |
|
454 | def test_destroy_leaf_project_without_confirmation_should_show_confirmation | |
455 | @request.session[:user_id] = 1 # admin |
|
455 | @request.session[:user_id] = 1 # admin | |
456 |
|
456 | |||
457 | assert_no_difference 'Project.count' do |
|
457 | assert_no_difference 'Project.count' do | |
458 | delete :destroy, :id => 2 |
|
458 | delete :destroy, :id => 2 | |
459 | assert_response :success |
|
459 | assert_response :success | |
460 | assert_template 'destroy' |
|
460 | assert_template 'destroy' | |
461 | end |
|
461 | end | |
462 | end |
|
462 | end | |
463 |
|
463 | |||
464 | def test_destroy_without_confirmation_should_show_confirmation_with_subprojects |
|
464 | def test_destroy_without_confirmation_should_show_confirmation_with_subprojects | |
465 | @request.session[:user_id] = 1 # admin |
|
465 | @request.session[:user_id] = 1 # admin | |
466 |
|
466 | |||
467 | assert_no_difference 'Project.count' do |
|
467 | assert_no_difference 'Project.count' do | |
468 | delete :destroy, :id => 1 |
|
468 | delete :destroy, :id => 1 | |
469 | assert_response :success |
|
469 | assert_response :success | |
470 | assert_template 'destroy' |
|
470 | assert_template 'destroy' | |
471 | end |
|
471 | end | |
472 | assert_select 'strong', |
|
472 | assert_select 'strong', | |
473 | :text => ['Private child of eCookbook', |
|
473 | :text => ['Private child of eCookbook', | |
474 | 'Child of private child, eCookbook Subproject 1', |
|
474 | 'Child of private child, eCookbook Subproject 1', | |
475 | 'eCookbook Subproject 2'].join(', ') |
|
475 | 'eCookbook Subproject 2'].join(', ') | |
476 | end |
|
476 | end | |
477 |
|
477 | |||
478 | def test_destroy_with_confirmation_should_destroy_the_project_and_subprojects |
|
478 | def test_destroy_with_confirmation_should_destroy_the_project_and_subprojects | |
479 | @request.session[:user_id] = 1 # admin |
|
479 | @request.session[:user_id] = 1 # admin | |
480 |
|
480 | |||
481 | assert_difference 'Project.count', -5 do |
|
481 | assert_difference 'Project.count', -5 do | |
482 | delete :destroy, :id => 1, :confirm => 1 |
|
482 | delete :destroy, :id => 1, :confirm => 1 | |
483 | assert_redirected_to '/admin/projects' |
|
483 | assert_redirected_to '/admin/projects' | |
484 | end |
|
484 | end | |
485 | assert_nil Project.find_by_id(1) |
|
485 | assert_nil Project.find_by_id(1) | |
486 | end |
|
486 | end | |
487 |
|
487 | |||
488 | def test_archive |
|
488 | def test_archive | |
489 | @request.session[:user_id] = 1 # admin |
|
489 | @request.session[:user_id] = 1 # admin | |
490 | post :archive, :id => 1 |
|
490 | post :archive, :id => 1 | |
491 | assert_redirected_to '/admin/projects' |
|
491 | assert_redirected_to '/admin/projects' | |
492 | assert !Project.find(1).active? |
|
492 | assert !Project.find(1).active? | |
493 | end |
|
493 | end | |
494 |
|
494 | |||
495 | def test_archive_with_failure |
|
495 | def test_archive_with_failure | |
496 | @request.session[:user_id] = 1 |
|
496 | @request.session[:user_id] = 1 | |
497 | Project.any_instance.stubs(:archive).returns(false) |
|
497 | Project.any_instance.stubs(:archive).returns(false) | |
498 | post :archive, :id => 1 |
|
498 | post :archive, :id => 1 | |
499 | assert_redirected_to '/admin/projects' |
|
499 | assert_redirected_to '/admin/projects' | |
500 | assert_match /project cannot be archived/i, flash[:error] |
|
500 | assert_match /project cannot be archived/i, flash[:error] | |
501 | end |
|
501 | end | |
502 |
|
502 | |||
503 | def test_unarchive |
|
503 | def test_unarchive | |
504 | @request.session[:user_id] = 1 # admin |
|
504 | @request.session[:user_id] = 1 # admin | |
505 | Project.find(1).archive |
|
505 | Project.find(1).archive | |
506 | post :unarchive, :id => 1 |
|
506 | post :unarchive, :id => 1 | |
507 | assert_redirected_to '/admin/projects' |
|
507 | assert_redirected_to '/admin/projects' | |
508 | assert Project.find(1).active? |
|
508 | assert Project.find(1).active? | |
509 | end |
|
509 | end | |
510 |
|
510 | |||
511 | def test_close |
|
511 | def test_close | |
512 | @request.session[:user_id] = 2 |
|
512 | @request.session[:user_id] = 2 | |
513 | post :close, :id => 1 |
|
513 | post :close, :id => 1 | |
514 | assert_redirected_to '/projects/ecookbook' |
|
514 | assert_redirected_to '/projects/ecookbook' | |
515 | assert_equal Project::STATUS_CLOSED, Project.find(1).status |
|
515 | assert_equal Project::STATUS_CLOSED, Project.find(1).status | |
516 | end |
|
516 | end | |
517 |
|
517 | |||
518 | def test_reopen |
|
518 | def test_reopen | |
519 | Project.find(1).close |
|
519 | Project.find(1).close | |
520 | @request.session[:user_id] = 2 |
|
520 | @request.session[:user_id] = 2 | |
521 | post :reopen, :id => 1 |
|
521 | post :reopen, :id => 1 | |
522 | assert_redirected_to '/projects/ecookbook' |
|
522 | assert_redirected_to '/projects/ecookbook' | |
523 | assert Project.find(1).active? |
|
523 | assert Project.find(1).active? | |
524 | end |
|
524 | end | |
525 |
|
525 | |||
526 | def test_project_breadcrumbs_should_be_limited_to_3_ancestors |
|
526 | def test_project_breadcrumbs_should_be_limited_to_3_ancestors | |
527 | CustomField.delete_all |
|
527 | CustomField.delete_all | |
528 | parent = nil |
|
528 | parent = nil | |
529 | 6.times do |i| |
|
529 | 6.times do |i| | |
530 | p = Project.generate_with_parent!(parent) |
|
530 | p = Project.generate_with_parent!(parent) | |
531 | get :show, :id => p |
|
531 | get :show, :id => p | |
532 | assert_select '#header h1' do |
|
532 | assert_select '#header h1' do | |
533 | assert_select 'a', :count => [i, 3].min |
|
533 | assert_select 'a', :count => [i, 3].min | |
534 | end |
|
534 | end | |
535 |
|
535 | |||
536 | parent = p |
|
536 | parent = p | |
537 | end |
|
537 | end | |
538 | end |
|
538 | end | |
539 |
|
539 | |||
540 | def test_get_copy |
|
540 | def test_get_copy | |
541 | @request.session[:user_id] = 1 # admin |
|
541 | @request.session[:user_id] = 1 # admin | |
542 | get :copy, :id => 1 |
|
542 | get :copy, :id => 1 | |
543 | assert_response :success |
|
543 | assert_response :success | |
544 | assert_template 'copy' |
|
544 | assert_template 'copy' | |
545 | assert assigns(:project) |
|
545 | assert assigns(:project) | |
546 | assert_equal Project.find(1).description, assigns(:project).description |
|
546 | assert_equal Project.find(1).description, assigns(:project).description | |
547 | assert_nil assigns(:project).id |
|
547 | assert_nil assigns(:project).id | |
548 |
|
548 | |||
549 | assert_select 'input[name=?][value=?]', 'project[enabled_module_names][]', 'issue_tracking', 1 |
|
549 | assert_select 'input[name=?][value=?]', 'project[enabled_module_names][]', 'issue_tracking', 1 | |
550 | end |
|
550 | end | |
551 |
|
551 | |||
552 | def test_get_copy_with_invalid_source_should_respond_with_404 |
|
552 | def test_get_copy_with_invalid_source_should_respond_with_404 | |
553 | @request.session[:user_id] = 1 |
|
553 | @request.session[:user_id] = 1 | |
554 | get :copy, :id => 99 |
|
554 | get :copy, :id => 99 | |
555 | assert_response 404 |
|
555 | assert_response 404 | |
556 | end |
|
556 | end | |
557 |
|
557 | |||
558 | def test_post_copy_should_copy_requested_items |
|
558 | def test_post_copy_should_copy_requested_items | |
559 | @request.session[:user_id] = 1 # admin |
|
559 | @request.session[:user_id] = 1 # admin | |
560 | CustomField.delete_all |
|
560 | CustomField.delete_all | |
561 |
|
561 | |||
562 | assert_difference 'Project.count' do |
|
562 | assert_difference 'Project.count' do | |
563 | post :copy, :id => 1, |
|
563 | post :copy, :id => 1, | |
564 | :project => { |
|
564 | :project => { | |
565 | :name => 'Copy', |
|
565 | :name => 'Copy', | |
566 | :identifier => 'unique-copy', |
|
566 | :identifier => 'unique-copy', | |
567 | :tracker_ids => ['1', '2', '3', ''], |
|
567 | :tracker_ids => ['1', '2', '3', ''], | |
568 | :enabled_module_names => %w(issue_tracking time_tracking) |
|
568 | :enabled_module_names => %w(issue_tracking time_tracking) | |
569 | }, |
|
569 | }, | |
570 | :only => %w(issues versions) |
|
570 | :only => %w(issues versions) | |
571 | end |
|
571 | end | |
572 | project = Project.find('unique-copy') |
|
572 | project = Project.find('unique-copy') | |
573 | source = Project.find(1) |
|
573 | source = Project.find(1) | |
574 | assert_equal %w(issue_tracking time_tracking), project.enabled_module_names.sort |
|
574 | assert_equal %w(issue_tracking time_tracking), project.enabled_module_names.sort | |
575 |
|
575 | |||
576 | assert_equal source.versions.count, project.versions.count, "All versions were not copied" |
|
576 | assert_equal source.versions.count, project.versions.count, "All versions were not copied" | |
577 | assert_equal source.issues.count, project.issues.count, "All issues were not copied" |
|
577 | assert_equal source.issues.count, project.issues.count, "All issues were not copied" | |
578 | assert_equal 0, project.members.count |
|
578 | assert_equal 0, project.members.count | |
579 | end |
|
579 | end | |
580 |
|
580 | |||
581 | def test_post_copy_should_redirect_to_settings_when_successful |
|
581 | def test_post_copy_should_redirect_to_settings_when_successful | |
582 | @request.session[:user_id] = 1 # admin |
|
582 | @request.session[:user_id] = 1 # admin | |
583 | post :copy, :id => 1, :project => {:name => 'Copy', :identifier => 'unique-copy'} |
|
583 | post :copy, :id => 1, :project => {:name => 'Copy', :identifier => 'unique-copy'} | |
584 | assert_response :redirect |
|
584 | assert_response :redirect | |
585 | assert_redirected_to :controller => 'projects', :action => 'settings', :id => 'unique-copy' |
|
585 | assert_redirected_to :controller => 'projects', :action => 'settings', :id => 'unique-copy' | |
586 | end |
|
586 | end | |
587 |
|
587 | |||
588 | def test_jump_should_redirect_to_active_tab |
|
588 | def test_jump_should_redirect_to_active_tab | |
589 | get :show, :id => 1, :jump => 'issues' |
|
589 | get :show, :id => 1, :jump => 'issues' | |
590 | assert_redirected_to '/projects/ecookbook/issues' |
|
590 | assert_redirected_to '/projects/ecookbook/issues' | |
591 | end |
|
591 | end | |
592 |
|
592 | |||
593 | def test_jump_should_not_redirect_to_inactive_tab |
|
593 | def test_jump_should_not_redirect_to_inactive_tab | |
594 | get :show, :id => 3, :jump => 'documents' |
|
594 | get :show, :id => 3, :jump => 'documents' | |
595 | assert_response :success |
|
595 | assert_response :success | |
596 | assert_template 'show' |
|
596 | assert_template 'show' | |
597 | end |
|
597 | end | |
598 |
|
598 | |||
599 | def test_jump_should_not_redirect_to_unknown_tab |
|
599 | def test_jump_should_not_redirect_to_unknown_tab | |
600 | get :show, :id => 3, :jump => 'foobar' |
|
600 | get :show, :id => 3, :jump => 'foobar' | |
601 | assert_response :success |
|
601 | assert_response :success | |
602 | assert_template 'show' |
|
602 | assert_template 'show' | |
603 | end |
|
603 | end | |
604 |
|
604 | |||
605 | def test_body_should_have_project_css_class |
|
605 | def test_body_should_have_project_css_class | |
606 | get :show, :id => 1 |
|
606 | get :show, :id => 1 | |
607 | assert_select 'body.project-ecookbook' |
|
607 | assert_select 'body.project-ecookbook' | |
608 | end |
|
608 | end | |
609 | end |
|
609 | end |
General Comments 0
You need to be logged in to leave comments.
Login now