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