Mercurial > hg > soundsoftware-site
comparison test/unit/project_test.rb @ 909:cbb26bc654de redmine-1.3
Update to Redmine 1.3-stable branch (Redmine SVN rev 8964)
author | Chris Cannam |
---|---|
date | Fri, 24 Feb 2012 19:09:32 +0000 |
parents | 0c939c159af4 |
children | 5f33065ddc4b |
comparison
equal
deleted
inserted
replaced
908:c6c2cbd0afee | 909:cbb26bc654de |
---|---|
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 ProjectTest < ActiveSupport::TestCase | 20 class ProjectTest < ActiveSupport::TestCase |
21 fixtures :all | 21 fixtures :projects, :trackers, :issue_statuses, :issues, |
22 :enumerations, :users, :issue_categories, | |
23 :projects_trackers, | |
24 :roles, | |
25 :member_roles, | |
26 :members, | |
27 :enabled_modules, | |
28 :workflows, | |
29 :versions, | |
30 :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions, | |
31 :groups_users, | |
32 :boards | |
22 | 33 |
23 def setup | 34 def setup |
24 @ecookbook = Project.find(1) | 35 @ecookbook = Project.find(1) |
25 @ecookbook_sub1 = Project.find(3) | 36 @ecookbook_sub1 = Project.find(3) |
26 User.current = nil | 37 User.current = nil |
27 end | 38 end |
28 | 39 |
29 should_validate_presence_of :name | 40 should_validate_presence_of :name |
30 should_validate_presence_of :identifier | 41 should_validate_presence_of :identifier |
31 | 42 |
32 should_validate_uniqueness_of :identifier | 43 should_validate_uniqueness_of :identifier |
33 | 44 |
57 | 68 |
58 def test_truth | 69 def test_truth |
59 assert_kind_of Project, @ecookbook | 70 assert_kind_of Project, @ecookbook |
60 assert_equal "eCookbook", @ecookbook.name | 71 assert_equal "eCookbook", @ecookbook.name |
61 end | 72 end |
62 | 73 |
63 def test_default_attributes | 74 def test_default_attributes |
64 with_settings :default_projects_public => '1' do | 75 with_settings :default_projects_public => '1' do |
65 assert_equal true, Project.new.is_public | 76 assert_equal true, Project.new.is_public |
66 assert_equal false, Project.new(:is_public => false).is_public | 77 assert_equal false, Project.new(:is_public => false).is_public |
67 end | 78 end |
82 end | 93 end |
83 | 94 |
84 with_settings :default_projects_modules => ['issue_tracking', 'repository'] do | 95 with_settings :default_projects_modules => ['issue_tracking', 'repository'] do |
85 assert_equal ['issue_tracking', 'repository'], Project.new.enabled_module_names | 96 assert_equal ['issue_tracking', 'repository'], Project.new.enabled_module_names |
86 end | 97 end |
87 | 98 |
88 assert_equal Tracker.all, Project.new.trackers | 99 assert_equal Tracker.all, Project.new.trackers |
89 assert_equal Tracker.find(1, 3), Project.new(:tracker_ids => [1, 3]).trackers | 100 assert_equal Tracker.find(1, 3), Project.new(:tracker_ids => [1, 3]).trackers |
90 end | 101 end |
91 | 102 |
92 def test_update | 103 def test_update |
93 assert_equal "eCookbook", @ecookbook.name | 104 assert_equal "eCookbook", @ecookbook.name |
94 @ecookbook.name = "eCook" | 105 @ecookbook.name = "eCook" |
95 assert @ecookbook.save, @ecookbook.errors.full_messages.join("; ") | 106 assert @ecookbook.save, @ecookbook.errors.full_messages.join("; ") |
96 @ecookbook.reload | 107 @ecookbook.reload |
97 assert_equal "eCook", @ecookbook.name | 108 assert_equal "eCook", @ecookbook.name |
98 end | 109 end |
99 | 110 |
100 def test_validate_identifier | 111 def test_validate_identifier |
101 to_test = {"abc" => true, | 112 to_test = {"abc" => true, |
102 "ab12" => true, | 113 "ab12" => true, |
103 "ab-12" => true, | 114 "ab-12" => true, |
104 "12" => false, | 115 "12" => false, |
105 "new" => false} | 116 "new" => false} |
106 | 117 |
107 to_test.each do |identifier, valid| | 118 to_test.each do |identifier, valid| |
108 p = Project.new | 119 p = Project.new |
109 p.identifier = identifier | 120 p.identifier = identifier |
110 p.valid? | 121 p.valid? |
111 assert_equal valid, p.errors.on('identifier').nil? | 122 assert_equal valid, p.errors['identifier'].nil? |
112 end | 123 end |
113 end | 124 end |
114 | 125 |
115 def test_members_should_be_active_users | 126 def test_members_should_be_active_users |
116 Project.all.each do |project| | 127 Project.all.each do |project| |
117 assert_nil project.members.detect {|m| !(m.user.is_a?(User) && m.user.active?) } | 128 assert_nil project.members.detect {|m| !(m.user.is_a?(User) && m.user.active?) } |
118 end | 129 end |
119 end | 130 end |
120 | 131 |
121 def test_users_should_be_active_users | 132 def test_users_should_be_active_users |
122 Project.all.each do |project| | 133 Project.all.each do |project| |
123 assert_nil project.users.detect {|u| !(u.is_a?(User) && u.active?) } | 134 assert_nil project.users.detect {|u| !(u.is_a?(User) && u.active?) } |
124 end | 135 end |
125 end | 136 end |
126 | 137 |
127 def test_archive | 138 def test_archive |
128 user = @ecookbook.members.first.user | 139 user = @ecookbook.members.first.user |
129 @ecookbook.archive | 140 @ecookbook.archive |
130 @ecookbook.reload | 141 @ecookbook.reload |
131 | 142 |
132 assert !@ecookbook.active? | 143 assert !@ecookbook.active? |
133 assert @ecookbook.archived? | 144 assert @ecookbook.archived? |
134 assert !user.projects.include?(@ecookbook) | 145 assert !user.projects.include?(@ecookbook) |
135 # Subproject are also archived | 146 # Subproject are also archived |
136 assert !@ecookbook.children.empty? | 147 assert !@ecookbook.children.empty? |
137 assert @ecookbook.descendants.active.empty? | 148 assert @ecookbook.descendants.active.empty? |
138 end | 149 end |
139 | 150 |
140 def test_archive_should_fail_if_versions_are_used_by_non_descendant_projects | 151 def test_archive_should_fail_if_versions_are_used_by_non_descendant_projects |
141 # Assign an issue of a project to a version of a child project | 152 # Assign an issue of a project to a version of a child project |
142 Issue.find(4).update_attribute :fixed_version_id, 4 | 153 Issue.find(4).update_attribute :fixed_version_id, 4 |
143 | 154 |
144 assert_no_difference "Project.count(:all, :conditions => 'status = #{Project::STATUS_ARCHIVED}')" do | 155 assert_no_difference "Project.count(:all, :conditions => 'status = #{Project::STATUS_ARCHIVED}')" do |
145 assert_equal false, @ecookbook.archive | 156 assert_equal false, @ecookbook.archive |
146 end | 157 end |
147 @ecookbook.reload | 158 @ecookbook.reload |
148 assert @ecookbook.active? | 159 assert @ecookbook.active? |
149 end | 160 end |
150 | 161 |
151 def test_unarchive | 162 def test_unarchive |
152 user = @ecookbook.members.first.user | 163 user = @ecookbook.members.first.user |
153 @ecookbook.archive | 164 @ecookbook.archive |
154 # A subproject of an archived project can not be unarchived | 165 # A subproject of an archived project can not be unarchived |
155 assert !@ecookbook_sub1.unarchive | 166 assert !@ecookbook_sub1.unarchive |
156 | 167 |
157 # Unarchive project | 168 # Unarchive project |
158 assert @ecookbook.unarchive | 169 assert @ecookbook.unarchive |
159 @ecookbook.reload | 170 @ecookbook.reload |
160 assert @ecookbook.active? | 171 assert @ecookbook.active? |
161 assert !@ecookbook.archived? | 172 assert !@ecookbook.archived? |
162 assert user.projects.include?(@ecookbook) | 173 assert user.projects.include?(@ecookbook) |
163 # Subproject can now be unarchived | 174 # Subproject can now be unarchived |
164 @ecookbook_sub1.reload | 175 @ecookbook_sub1.reload |
165 assert @ecookbook_sub1.unarchive | 176 assert @ecookbook_sub1.unarchive |
166 end | 177 end |
167 | 178 |
168 def test_destroy | 179 def test_destroy |
169 # 2 active members | 180 # 2 active members |
170 assert_equal 2, @ecookbook.members.size | 181 assert_equal 2, @ecookbook.members.size |
171 # and 1 is locked | 182 # and 1 is locked |
172 assert_equal 3, Member.find(:all, :conditions => ['project_id = ?', @ecookbook.id]).size | 183 assert_equal 3, Member.find(:all, :conditions => ['project_id = ?', @ecookbook.id]).size |
173 # some boards | 184 # some boards |
174 assert @ecookbook.boards.any? | 185 assert @ecookbook.boards.any? |
175 | 186 |
176 @ecookbook.destroy | 187 @ecookbook.destroy |
177 # make sure that the project non longer exists | 188 # make sure that the project non longer exists |
178 assert_raise(ActiveRecord::RecordNotFound) { Project.find(@ecookbook.id) } | 189 assert_raise(ActiveRecord::RecordNotFound) { Project.find(@ecookbook.id) } |
179 # make sure related data was removed | 190 # make sure related data was removed |
180 assert_nil Member.first(:conditions => {:project_id => @ecookbook.id}) | 191 assert_nil Member.first(:conditions => {:project_id => @ecookbook.id}) |
181 assert_nil Board.first(:conditions => {:project_id => @ecookbook.id}) | 192 assert_nil Board.first(:conditions => {:project_id => @ecookbook.id}) |
182 assert_nil Issue.first(:conditions => {:project_id => @ecookbook.id}) | 193 assert_nil Issue.first(:conditions => {:project_id => @ecookbook.id}) |
183 end | 194 end |
184 | 195 |
185 def test_destroying_root_projects_should_clear_data | 196 def test_destroying_root_projects_should_clear_data |
186 Project.roots.each do |root| | 197 Project.roots.each do |root| |
187 root.destroy | 198 root.destroy |
188 end | 199 end |
189 | 200 |
190 assert_equal 0, Project.count, "Projects were not deleted: #{Project.all.inspect}" | 201 assert_equal 0, Project.count, "Projects were not deleted: #{Project.all.inspect}" |
191 assert_equal 0, Member.count, "Members were not deleted: #{Member.all.inspect}" | 202 assert_equal 0, Member.count, "Members were not deleted: #{Member.all.inspect}" |
192 assert_equal 0, MemberRole.count | 203 assert_equal 0, MemberRole.count |
193 assert_equal 0, Issue.count | 204 assert_equal 0, Issue.count |
194 assert_equal 0, Journal.count | 205 assert_equal 0, Journal.count |
214 assert_equal 0, WikiContent::Version.count | 225 assert_equal 0, WikiContent::Version.count |
215 assert_equal 0, Project.connection.select_all("SELECT * FROM projects_trackers").size | 226 assert_equal 0, Project.connection.select_all("SELECT * FROM projects_trackers").size |
216 assert_equal 0, Project.connection.select_all("SELECT * FROM custom_fields_projects").size | 227 assert_equal 0, Project.connection.select_all("SELECT * FROM custom_fields_projects").size |
217 assert_equal 0, CustomValue.count(:conditions => {:customized_type => ['Project', 'Issue', 'TimeEntry', 'Version']}) | 228 assert_equal 0, CustomValue.count(:conditions => {:customized_type => ['Project', 'Issue', 'TimeEntry', 'Version']}) |
218 end | 229 end |
219 | 230 |
220 def test_move_an_orphan_project_to_a_root_project | 231 def test_move_an_orphan_project_to_a_root_project |
221 sub = Project.find(2) | 232 sub = Project.find(2) |
222 sub.set_parent! @ecookbook | 233 sub.set_parent! @ecookbook |
223 assert_equal @ecookbook.id, sub.parent.id | 234 assert_equal @ecookbook.id, sub.parent.id |
224 @ecookbook.reload | 235 @ecookbook.reload |
225 assert_equal 4, @ecookbook.children.size | 236 assert_equal 4, @ecookbook.children.size |
226 end | 237 end |
227 | 238 |
228 def test_move_an_orphan_project_to_a_subproject | 239 def test_move_an_orphan_project_to_a_subproject |
229 sub = Project.find(2) | 240 sub = Project.find(2) |
230 assert sub.set_parent!(@ecookbook_sub1) | 241 assert sub.set_parent!(@ecookbook_sub1) |
231 end | 242 end |
232 | 243 |
233 def test_move_a_root_project_to_a_project | 244 def test_move_a_root_project_to_a_project |
234 sub = @ecookbook | 245 sub = @ecookbook |
235 assert sub.set_parent!(Project.find(2)) | 246 assert sub.set_parent!(Project.find(2)) |
236 end | 247 end |
237 | 248 |
238 def test_should_not_move_a_project_to_its_children | 249 def test_should_not_move_a_project_to_its_children |
239 sub = @ecookbook | 250 sub = @ecookbook |
240 assert !(sub.set_parent!(Project.find(3))) | 251 assert !(sub.set_parent!(Project.find(3))) |
241 end | 252 end |
242 | 253 |
243 def test_set_parent_should_add_roots_in_alphabetical_order | 254 def test_set_parent_should_add_roots_in_alphabetical_order |
244 ProjectCustomField.delete_all | 255 ProjectCustomField.delete_all |
245 Project.delete_all | 256 Project.delete_all |
246 Project.create!(:name => 'Project C', :identifier => 'project-c').set_parent!(nil) | 257 Project.create!(:name => 'Project C', :identifier => 'project-c').set_parent!(nil) |
247 Project.create!(:name => 'Project B', :identifier => 'project-b').set_parent!(nil) | 258 Project.create!(:name => 'Project B', :identifier => 'project-b').set_parent!(nil) |
248 Project.create!(:name => 'Project D', :identifier => 'project-d').set_parent!(nil) | 259 Project.create!(:name => 'Project D', :identifier => 'project-d').set_parent!(nil) |
249 Project.create!(:name => 'Project A', :identifier => 'project-a').set_parent!(nil) | 260 Project.create!(:name => 'Project A', :identifier => 'project-a').set_parent!(nil) |
250 | 261 |
251 assert_equal 4, Project.count | 262 assert_equal 4, Project.count |
252 assert_equal Project.all.sort_by(&:name), Project.all.sort_by(&:lft) | 263 assert_equal Project.all.sort_by(&:name), Project.all.sort_by(&:lft) |
253 end | 264 end |
254 | 265 |
255 def test_set_parent_should_add_children_in_alphabetical_order | 266 def test_set_parent_should_add_children_in_alphabetical_order |
256 ProjectCustomField.delete_all | 267 ProjectCustomField.delete_all |
257 parent = Project.create!(:name => 'Parent', :identifier => 'parent') | 268 parent = Project.create!(:name => 'Parent', :identifier => 'parent') |
258 Project.create!(:name => 'Project C', :identifier => 'project-c').set_parent!(parent) | 269 Project.create!(:name => 'Project C', :identifier => 'project-c').set_parent!(parent) |
259 Project.create!(:name => 'Project B', :identifier => 'project-b').set_parent!(parent) | 270 Project.create!(:name => 'Project B', :identifier => 'project-b').set_parent!(parent) |
260 Project.create!(:name => 'Project D', :identifier => 'project-d').set_parent!(parent) | 271 Project.create!(:name => 'Project D', :identifier => 'project-d').set_parent!(parent) |
261 Project.create!(:name => 'Project A', :identifier => 'project-a').set_parent!(parent) | 272 Project.create!(:name => 'Project A', :identifier => 'project-a').set_parent!(parent) |
262 | 273 |
263 parent.reload | 274 parent.reload |
264 assert_equal 4, parent.children.size | 275 assert_equal 4, parent.children.size |
265 assert_equal parent.children.sort_by(&:name), parent.children | 276 assert_equal parent.children.sort_by(&:name), parent.children |
266 end | 277 end |
267 | 278 |
268 def test_rebuild_should_sort_children_alphabetically | 279 def test_rebuild_should_sort_children_alphabetically |
269 ProjectCustomField.delete_all | 280 ProjectCustomField.delete_all |
270 parent = Project.create!(:name => 'Parent', :identifier => 'parent') | 281 parent = Project.create!(:name => 'Parent', :identifier => 'parent') |
271 Project.create!(:name => 'Project C', :identifier => 'project-c').move_to_child_of(parent) | 282 Project.create!(:name => 'Project C', :identifier => 'project-c').move_to_child_of(parent) |
272 Project.create!(:name => 'Project B', :identifier => 'project-b').move_to_child_of(parent) | 283 Project.create!(:name => 'Project B', :identifier => 'project-b').move_to_child_of(parent) |
273 Project.create!(:name => 'Project D', :identifier => 'project-d').move_to_child_of(parent) | 284 Project.create!(:name => 'Project D', :identifier => 'project-d').move_to_child_of(parent) |
274 Project.create!(:name => 'Project A', :identifier => 'project-a').move_to_child_of(parent) | 285 Project.create!(:name => 'Project A', :identifier => 'project-a').move_to_child_of(parent) |
275 | 286 |
276 Project.update_all("lft = NULL, rgt = NULL") | 287 Project.update_all("lft = NULL, rgt = NULL") |
277 Project.rebuild! | 288 Project.rebuild! |
278 | 289 |
279 parent.reload | 290 parent.reload |
280 assert_equal 4, parent.children.size | 291 assert_equal 4, parent.children.size |
281 assert_equal parent.children.sort_by(&:name), parent.children | 292 assert_equal parent.children.sort_by(&:name), parent.children |
282 end | 293 end |
283 | 294 |
298 # Local issue with hierarchy fixed_version | 309 # Local issue with hierarchy fixed_version |
299 issue_with_hierarchy_fixed_version = Issue.find(13) | 310 issue_with_hierarchy_fixed_version = Issue.find(13) |
300 issue_with_hierarchy_fixed_version.update_attribute(:fixed_version_id, 6) | 311 issue_with_hierarchy_fixed_version.update_attribute(:fixed_version_id, 6) |
301 issue_with_hierarchy_fixed_version.reload | 312 issue_with_hierarchy_fixed_version.reload |
302 assert_equal 6, issue_with_hierarchy_fixed_version.fixed_version_id | 313 assert_equal 6, issue_with_hierarchy_fixed_version.fixed_version_id |
303 | 314 |
304 # Move project out of the issue's hierarchy | 315 # Move project out of the issue's hierarchy |
305 moved_project = Project.find(3) | 316 moved_project = Project.find(3) |
306 moved_project.set_parent!(Project.find(2)) | 317 moved_project.set_parent!(Project.find(2)) |
307 parent_issue.reload | 318 parent_issue.reload |
308 issue_with_local_fixed_version.reload | 319 issue_with_local_fixed_version.reload |
309 issue_with_hierarchy_fixed_version.reload | 320 issue_with_hierarchy_fixed_version.reload |
310 | 321 |
311 assert_equal 4, issue_with_local_fixed_version.fixed_version_id, "Fixed version was not keep on an issue local to the moved project" | 322 assert_equal 4, issue_with_local_fixed_version.fixed_version_id, "Fixed version was not keep on an issue local to the moved project" |
312 assert_equal nil, issue_with_hierarchy_fixed_version.fixed_version_id, "Fixed version is still set after moving the Project out of the hierarchy where the version is defined in" | 323 assert_equal nil, issue_with_hierarchy_fixed_version.fixed_version_id, "Fixed version is still set after moving the Project out of the hierarchy where the version is defined in" |
313 assert_equal nil, parent_issue.fixed_version_id, "Fixed version is still set after moving the Version out of the hierarchy for the issue." | 324 assert_equal nil, parent_issue.fixed_version_id, "Fixed version is still set after moving the Version out of the hierarchy for the issue." |
314 end | 325 end |
315 | 326 |
316 def test_parent | 327 def test_parent |
317 p = Project.find(6).parent | 328 p = Project.find(6).parent |
318 assert p.is_a?(Project) | 329 assert p.is_a?(Project) |
319 assert_equal 5, p.id | 330 assert_equal 5, p.id |
320 end | 331 end |
321 | 332 |
322 def test_ancestors | 333 def test_ancestors |
323 a = Project.find(6).ancestors | 334 a = Project.find(6).ancestors |
324 assert a.first.is_a?(Project) | 335 assert a.first.is_a?(Project) |
325 assert_equal [1, 5], a.collect(&:id) | 336 assert_equal [1, 5], a.collect(&:id) |
326 end | 337 end |
327 | 338 |
328 def test_root | 339 def test_root |
329 r = Project.find(6).root | 340 r = Project.find(6).root |
330 assert r.is_a?(Project) | 341 assert r.is_a?(Project) |
331 assert_equal 1, r.id | 342 assert_equal 1, r.id |
332 end | 343 end |
333 | 344 |
334 def test_children | 345 def test_children |
335 c = Project.find(1).children | 346 c = Project.find(1).children |
336 assert c.first.is_a?(Project) | 347 assert c.first.is_a?(Project) |
337 assert_equal [5, 3, 4], c.collect(&:id) | 348 assert_equal [5, 3, 4], c.collect(&:id) |
338 end | 349 end |
339 | 350 |
340 def test_descendants | 351 def test_descendants |
341 d = Project.find(1).descendants | 352 d = Project.find(1).descendants |
342 assert d.first.is_a?(Project) | 353 assert d.first.is_a?(Project) |
343 assert_equal [5, 6, 3, 4], d.collect(&:id) | 354 assert_equal [5, 6, 3, 4], d.collect(&:id) |
344 end | 355 end |
345 | 356 |
346 def test_allowed_parents_should_be_empty_for_non_member_user | 357 def test_allowed_parents_should_be_empty_for_non_member_user |
347 Role.non_member.add_permission!(:add_project) | 358 Role.non_member.add_permission!(:add_project) |
348 user = User.find(9) | 359 user = User.find(9) |
349 assert user.memberships.empty? | 360 assert user.memberships.empty? |
350 User.current = user | 361 User.current = user |
351 assert Project.new.allowed_parents.compact.empty? | 362 assert Project.new.allowed_parents.compact.empty? |
352 end | 363 end |
353 | 364 |
354 def test_allowed_parents_with_add_subprojects_permission | 365 def test_allowed_parents_with_add_subprojects_permission |
355 Role.find(1).remove_permission!(:add_project) | 366 Role.find(1).remove_permission!(:add_project) |
356 Role.find(1).add_permission!(:add_subprojects) | 367 Role.find(1).add_permission!(:add_subprojects) |
357 User.current = User.find(2) | 368 User.current = User.find(2) |
358 # new project | 369 # new project |
390 assert Project.find(1).allowed_parents.include?(nil) | 401 assert Project.find(1).allowed_parents.include?(nil) |
391 # existing child | 402 # existing child |
392 assert Project.find(3).allowed_parents.include?(Project.find(1)) | 403 assert Project.find(3).allowed_parents.include?(Project.find(1)) |
393 assert Project.find(3).allowed_parents.include?(nil) | 404 assert Project.find(3).allowed_parents.include?(nil) |
394 end | 405 end |
395 | 406 |
396 def test_users_by_role | 407 def test_users_by_role |
397 users_by_role = Project.find(1).users_by_role | 408 users_by_role = Project.find(1).users_by_role |
398 assert_kind_of Hash, users_by_role | 409 assert_kind_of Hash, users_by_role |
399 role = Role.find(1) | 410 role = Role.find(1) |
400 assert_kind_of Array, users_by_role[role] | 411 assert_kind_of Array, users_by_role[role] |
401 assert users_by_role[role].include?(User.find(2)) | 412 assert users_by_role[role].include?(User.find(2)) |
402 end | 413 end |
403 | 414 |
404 def test_rolled_up_trackers | 415 def test_rolled_up_trackers |
405 parent = Project.find(1) | 416 parent = Project.find(1) |
406 parent.trackers = Tracker.find([1,2]) | 417 parent.trackers = Tracker.find([1,2]) |
407 child = parent.children.find(3) | 418 child = parent.children.find(3) |
408 | 419 |
409 assert_equal [1, 2], parent.tracker_ids | 420 assert_equal [1, 2], parent.tracker_ids |
410 assert_equal [2, 3], child.trackers.collect(&:id) | 421 assert_equal [2, 3], child.trackers.collect(&:id) |
411 | 422 |
412 assert_kind_of Tracker, parent.rolled_up_trackers.first | 423 assert_kind_of Tracker, parent.rolled_up_trackers.first |
413 assert_equal Tracker.find(1), parent.rolled_up_trackers.first | 424 assert_equal Tracker.find(1), parent.rolled_up_trackers.first |
414 | 425 |
415 assert_equal [1, 2, 3], parent.rolled_up_trackers.collect(&:id) | 426 assert_equal [1, 2, 3], parent.rolled_up_trackers.collect(&:id) |
416 assert_equal [2, 3], child.rolled_up_trackers.collect(&:id) | 427 assert_equal [2, 3], child.rolled_up_trackers.collect(&:id) |
417 end | 428 end |
418 | 429 |
419 def test_rolled_up_trackers_should_ignore_archived_subprojects | 430 def test_rolled_up_trackers_should_ignore_archived_subprojects |
420 parent = Project.find(1) | 431 parent = Project.find(1) |
421 parent.trackers = Tracker.find([1,2]) | 432 parent.trackers = Tracker.find([1,2]) |
422 child = parent.children.find(3) | 433 child = parent.children.find(3) |
423 child.trackers = Tracker.find([1,3]) | 434 child.trackers = Tracker.find([1,3]) |
424 parent.children.each(&:archive) | 435 parent.children.each(&:archive) |
425 | 436 |
426 assert_equal [1,2], parent.rolled_up_trackers.collect(&:id) | 437 assert_equal [1,2], parent.rolled_up_trackers.collect(&:id) |
427 end | 438 end |
428 | 439 |
429 context "#rolled_up_versions" do | 440 context "#rolled_up_versions" do |
430 setup do | 441 setup do |
431 @project = Project.generate! | 442 @project = Project.generate! |
432 @parent_version_1 = Version.generate!(:project => @project) | 443 @parent_version_1 = Version.generate!(:project => @project) |
433 @parent_version_2 = Version.generate!(:project => @project) | 444 @parent_version_2 = Version.generate!(:project => @project) |
434 end | 445 end |
435 | 446 |
436 should "include the versions for the current project" do | 447 should "include the versions for the current project" do |
437 assert_same_elements [@parent_version_1, @parent_version_2], @project.rolled_up_versions | 448 assert_same_elements [@parent_version_1, @parent_version_2], @project.rolled_up_versions |
438 end | 449 end |
439 | 450 |
440 should "include versions for a subproject" do | 451 should "include versions for a subproject" do |
441 @subproject = Project.generate! | 452 @subproject = Project.generate! |
442 @subproject.set_parent!(@project) | 453 @subproject.set_parent!(@project) |
443 @subproject_version = Version.generate!(:project => @subproject) | 454 @subproject_version = Version.generate!(:project => @subproject) |
444 | 455 |
446 @parent_version_1, | 457 @parent_version_1, |
447 @parent_version_2, | 458 @parent_version_2, |
448 @subproject_version | 459 @subproject_version |
449 ], @project.rolled_up_versions | 460 ], @project.rolled_up_versions |
450 end | 461 end |
451 | 462 |
452 should "include versions for a sub-subproject" do | 463 should "include versions for a sub-subproject" do |
453 @subproject = Project.generate! | 464 @subproject = Project.generate! |
454 @subproject.set_parent!(@project) | 465 @subproject.set_parent!(@project) |
455 @sub_subproject = Project.generate! | 466 @sub_subproject = Project.generate! |
456 @sub_subproject.set_parent!(@subproject) | 467 @sub_subproject.set_parent!(@subproject) |
463 @parent_version_2, | 474 @parent_version_2, |
464 @sub_subproject_version | 475 @sub_subproject_version |
465 ], @project.rolled_up_versions | 476 ], @project.rolled_up_versions |
466 end | 477 end |
467 | 478 |
468 | |
469 should "only check active projects" do | 479 should "only check active projects" do |
470 @subproject = Project.generate! | 480 @subproject = Project.generate! |
471 @subproject.set_parent!(@project) | 481 @subproject.set_parent!(@project) |
472 @subproject_version = Version.generate!(:project => @subproject) | 482 @subproject_version = Version.generate!(:project => @subproject) |
473 assert @subproject.archive | 483 assert @subproject.archive |
476 | 486 |
477 assert !@subproject.active? | 487 assert !@subproject.active? |
478 assert_same_elements [@parent_version_1, @parent_version_2], @project.rolled_up_versions | 488 assert_same_elements [@parent_version_1, @parent_version_2], @project.rolled_up_versions |
479 end | 489 end |
480 end | 490 end |
481 | 491 |
482 def test_shared_versions_none_sharing | 492 def test_shared_versions_none_sharing |
483 p = Project.find(5) | 493 p = Project.find(5) |
484 v = Version.create!(:name => 'none_sharing', :project => p, :sharing => 'none') | 494 v = Version.create!(:name => 'none_sharing', :project => p, :sharing => 'none') |
485 assert p.shared_versions.include?(v) | 495 assert p.shared_versions.include?(v) |
486 assert !p.children.first.shared_versions.include?(v) | 496 assert !p.children.first.shared_versions.include?(v) |
496 assert p.children.first.shared_versions.include?(v) | 506 assert p.children.first.shared_versions.include?(v) |
497 assert !p.root.shared_versions.include?(v) | 507 assert !p.root.shared_versions.include?(v) |
498 assert !p.siblings.first.shared_versions.include?(v) | 508 assert !p.siblings.first.shared_versions.include?(v) |
499 assert !p.root.siblings.first.shared_versions.include?(v) | 509 assert !p.root.siblings.first.shared_versions.include?(v) |
500 end | 510 end |
501 | 511 |
502 def test_shared_versions_hierarchy_sharing | 512 def test_shared_versions_hierarchy_sharing |
503 p = Project.find(5) | 513 p = Project.find(5) |
504 v = Version.create!(:name => 'hierarchy_sharing', :project => p, :sharing => 'hierarchy') | 514 v = Version.create!(:name => 'hierarchy_sharing', :project => p, :sharing => 'hierarchy') |
505 assert p.shared_versions.include?(v) | 515 assert p.shared_versions.include?(v) |
506 assert p.children.first.shared_versions.include?(v) | 516 assert p.children.first.shared_versions.include?(v) |
531 | 541 |
532 def test_shared_versions | 542 def test_shared_versions |
533 parent = Project.find(1) | 543 parent = Project.find(1) |
534 child = parent.children.find(3) | 544 child = parent.children.find(3) |
535 private_child = parent.children.find(5) | 545 private_child = parent.children.find(5) |
536 | 546 |
537 assert_equal [1,2,3], parent.version_ids.sort | 547 assert_equal [1,2,3], parent.version_ids.sort |
538 assert_equal [4], child.version_ids | 548 assert_equal [4], child.version_ids |
539 assert_equal [6], private_child.version_ids | 549 assert_equal [6], private_child.version_ids |
540 assert_equal [7], Version.find_all_by_sharing('system').collect(&:id) | 550 assert_equal [7], Version.find_all_by_sharing('system').collect(&:id) |
541 | 551 |
550 def test_shared_versions_should_ignore_archived_subprojects | 560 def test_shared_versions_should_ignore_archived_subprojects |
551 parent = Project.find(1) | 561 parent = Project.find(1) |
552 child = parent.children.find(3) | 562 child = parent.children.find(3) |
553 child.archive | 563 child.archive |
554 parent.reload | 564 parent.reload |
555 | 565 |
556 assert_equal [1,2,3], parent.version_ids.sort | 566 assert_equal [1,2,3], parent.version_ids.sort |
557 assert_equal [4], child.version_ids | 567 assert_equal [4], child.version_ids |
558 assert !parent.shared_versions.collect(&:id).include?(4) | 568 assert !parent.shared_versions.collect(&:id).include?(4) |
559 end | 569 end |
560 | 570 |
561 def test_shared_versions_visible_to_user | 571 def test_shared_versions_visible_to_user |
562 user = User.find(3) | 572 user = User.find(3) |
563 parent = Project.find(1) | 573 parent = Project.find(1) |
564 child = parent.children.find(5) | 574 child = parent.children.find(5) |
565 | 575 |
566 assert_equal [1,2,3], parent.version_ids.sort | 576 assert_equal [1,2,3], parent.version_ids.sort |
567 assert_equal [6], child.version_ids | 577 assert_equal [6], child.version_ids |
568 | 578 |
569 versions = parent.shared_versions.visible(user) | 579 versions = parent.shared_versions.visible(user) |
570 | 580 |
571 assert_equal 4, versions.size | 581 assert_equal 4, versions.size |
572 versions.each do |version| | 582 versions.each do |version| |
573 assert_kind_of Version, version | 583 assert_kind_of Version, version |
574 end | 584 end |
575 | 585 |
576 assert !versions.collect(&:id).include?(6) | 586 assert !versions.collect(&:id).include?(6) |
577 end | 587 end |
578 | 588 |
579 | |
580 def test_next_identifier | 589 def test_next_identifier |
581 ProjectCustomField.delete_all | 590 ProjectCustomField.delete_all |
582 Project.create!(:name => 'last', :identifier => 'p2008040') | 591 Project.create!(:name => 'last', :identifier => 'p2008040') |
583 assert_equal 'p2008041', Project.next_identifier | 592 assert_equal 'p2008041', Project.next_identifier |
584 end | 593 end |
585 | 594 |
586 def test_next_identifier_first_project | 595 def test_next_identifier_first_project |
587 Project.delete_all | 596 Project.delete_all |
588 assert_nil Project.next_identifier | 597 assert_nil Project.next_identifier |
589 end | 598 end |
590 | 599 |
591 def test_enabled_module_names | 600 def test_enabled_module_names |
592 with_settings :default_projects_modules => ['issue_tracking', 'repository'] do | 601 with_settings :default_projects_modules => ['issue_tracking', 'repository'] do |
593 project = Project.new | 602 project = Project.new |
594 | 603 |
595 project.enabled_module_names = %w(issue_tracking news) | 604 project.enabled_module_names = %w(issue_tracking news) |
596 assert_equal %w(issue_tracking news), project.enabled_module_names.sort | 605 assert_equal %w(issue_tracking news), project.enabled_module_names.sort |
597 end | 606 end |
598 end | 607 end |
599 | 608 |
665 assert copied_project | 674 assert copied_project |
666 # Cleared attributes | 675 # Cleared attributes |
667 assert copied_project.id.blank? | 676 assert copied_project.id.blank? |
668 assert copied_project.name.blank? | 677 assert copied_project.name.blank? |
669 assert copied_project.identifier.blank? | 678 assert copied_project.identifier.blank? |
670 | 679 |
671 # Duplicated attributes | 680 # Duplicated attributes |
672 assert_equal source_project.description, copied_project.description | 681 assert_equal source_project.description, copied_project.description |
673 assert_equal source_project.enabled_modules, copied_project.enabled_modules | 682 assert_equal source_project.enabled_modules, copied_project.enabled_modules |
674 assert_equal source_project.trackers, copied_project.trackers | 683 assert_equal source_project.trackers, copied_project.trackers |
675 | 684 |
743 project = Project.find(1) | 752 project = Project.find(1) |
744 system_activity = TimeEntryActivity.find_by_name('Design') | 753 system_activity = TimeEntryActivity.find_by_name('Design') |
745 assert system_activity.active? | 754 assert system_activity.active? |
746 overridden_activity = TimeEntryActivity.generate!(:project => project, :parent => system_activity, :active => false) | 755 overridden_activity = TimeEntryActivity.generate!(:project => project, :parent => system_activity, :active => false) |
747 assert overridden_activity.save! | 756 assert overridden_activity.save! |
748 | 757 |
749 assert !project.activities.include?(overridden_activity), "Inactive Project specific Activity not found" | 758 assert !project.activities.include?(overridden_activity), "Inactive Project specific Activity not found" |
750 assert !project.activities.include?(system_activity), "System activity found when the project has an inactive override" | 759 assert !project.activities.include?(system_activity), "System activity found when the project has an inactive override" |
751 end | 760 end |
752 | 761 |
753 def test_close_completed_versions | 762 def test_close_completed_versions |
754 Version.update_all("status = 'open'") | 763 Version.update_all("status = 'open'") |
755 project = Project.find(1) | 764 project = Project.find(1) |
756 assert_not_nil project.versions.detect {|v| v.completed? && v.status == 'open'} | 765 assert_not_nil project.versions.detect {|v| v.completed? && v.status == 'open'} |
757 assert_not_nil project.versions.detect {|v| !v.completed? && v.status == 'open'} | 766 assert_not_nil project.versions.detect {|v| !v.completed? && v.status == 'open'} |
785 @project.issues.each do |issue| | 794 @project.issues.each do |issue| |
786 assert issue.valid? | 795 assert issue.valid? |
787 assert ! issue.assigned_to.blank? | 796 assert ! issue.assigned_to.blank? |
788 assert_equal @project, issue.project | 797 assert_equal @project, issue.project |
789 end | 798 end |
790 | 799 |
791 copied_issue = @project.issues.first(:conditions => {:subject => "copy issue status"}) | 800 copied_issue = @project.issues.first(:conditions => {:subject => "copy issue status"}) |
792 assert copied_issue | 801 assert copied_issue |
793 assert copied_issue.status | 802 assert copied_issue.status |
794 assert_equal "Closed", copied_issue.status.name | 803 assert_equal "Closed", copied_issue.status.name |
795 end | 804 end |
802 Issue.generate_for_project!(@source_project, | 811 Issue.generate_for_project!(@source_project, |
803 :fixed_version_id => assigned_version.id, | 812 :fixed_version_id => assigned_version.id, |
804 :subject => "change the new issues to use the copied version", | 813 :subject => "change the new issues to use the copied version", |
805 :tracker_id => 1, | 814 :tracker_id => 1, |
806 :project_id => @source_project.id) | 815 :project_id => @source_project.id) |
807 | 816 |
808 assert @project.copy(@source_project) | 817 assert @project.copy(@source_project) |
809 @project.reload | 818 @project.reload |
810 copied_issue = @project.issues.first(:conditions => {:subject => "change the new issues to use the copied version"}) | 819 copied_issue = @project.issues.first(:conditions => {:subject => "change the new issues to use the copied version"}) |
811 | 820 |
812 assert copied_issue | 821 assert copied_issue |
859 @project.memberships.each do |membership| | 868 @project.memberships.each do |membership| |
860 assert membership | 869 assert membership |
861 assert_equal @project, membership.project | 870 assert_equal @project, membership.project |
862 end | 871 end |
863 end | 872 end |
864 | 873 |
865 should "copy memberships with groups and additional roles" do | 874 should "copy memberships with groups and additional roles" do |
866 group = Group.create!(:lastname => "Copy group") | 875 group = Group.create!(:lastname => "Copy group") |
867 user = User.find(7) | 876 user = User.find(7) |
868 group.users << user | 877 group.users << user |
869 # group role | 878 # group role |
870 Member.create!(:project_id => @source_project.id, :principal => group, :role_ids => [2]) | 879 Member.create!(:project_id => @source_project.id, :principal => group, :role_ids => [2]) |
871 member = Member.find_by_user_id_and_project_id(user.id, @source_project.id) | 880 member = Member.find_by_user_id_and_project_id(user.id, @source_project.id) |
872 # additional role | 881 # additional role |
886 assert_equal @source_project.queries.size, @project.queries.size | 895 assert_equal @source_project.queries.size, @project.queries.size |
887 @project.queries.each do |query| | 896 @project.queries.each do |query| |
888 assert query | 897 assert query |
889 assert_equal @project, query.project | 898 assert_equal @project, query.project |
890 end | 899 end |
900 assert_equal @source_project.queries.map(&:user_id).sort, @project.queries.map(&:user_id).sort | |
891 end | 901 end |
892 | 902 |
893 should "copy versions" do | 903 should "copy versions" do |
894 @source_project.versions << Version.generate! | 904 @source_project.versions << Version.generate! |
895 @source_project.versions << Version.generate! | 905 @source_project.versions << Version.generate! |
916 | 926 |
917 should "copy wiki pages and content with hierarchy" do | 927 should "copy wiki pages and content with hierarchy" do |
918 assert_difference 'WikiPage.count', @source_project.wiki.pages.size do | 928 assert_difference 'WikiPage.count', @source_project.wiki.pages.size do |
919 assert @project.copy(@source_project) | 929 assert @project.copy(@source_project) |
920 end | 930 end |
921 | 931 |
922 assert @project.wiki | 932 assert @project.wiki |
923 assert_equal @source_project.wiki.pages.size, @project.wiki.pages.size | 933 assert_equal @source_project.wiki.pages.size, @project.wiki.pages.size |
924 | 934 |
925 @project.wiki.pages.each do |wiki_page| | 935 @project.wiki.pages.each do |wiki_page| |
926 assert wiki_page.content | 936 assert wiki_page.content |
927 assert !@source_project.wiki.pages.include?(wiki_page) | 937 assert !@source_project.wiki.pages.include?(wiki_page) |
928 end | 938 end |
929 | 939 |
930 parent = @project.wiki.find_page('Parent_page') | 940 parent = @project.wiki.find_page('Parent_page') |
931 child1 = @project.wiki.find_page('Child_page_1') | 941 child1 = @project.wiki.find_page('Child_page_1') |
932 child2 = @project.wiki.find_page('Child_page_2') | 942 child2 = @project.wiki.find_page('Child_page_2') |
933 assert_equal parent, child1.parent | 943 assert_equal parent, child1.parent |
934 assert_equal parent, child2.parent | 944 assert_equal parent, child2.parent |
962 assert issue.category | 972 assert issue.category |
963 assert_equal "Stock management", issue.category.name # Same name | 973 assert_equal "Stock management", issue.category.name # Same name |
964 assert_not_equal IssueCategory.find(3), issue.category # Different record | 974 assert_not_equal IssueCategory.find(3), issue.category # Different record |
965 end | 975 end |
966 end | 976 end |
967 | 977 |
968 should "limit copy with :only option" do | 978 should "limit copy with :only option" do |
969 assert @project.members.empty? | 979 assert @project.members.empty? |
970 assert @project.issue_categories.empty? | 980 assert @project.issue_categories.empty? |
971 assert @source_project.issues.any? | 981 assert @source_project.issues.any? |
972 | 982 |
973 assert @project.copy(@source_project, :only => ['members', 'issue_categories']) | 983 assert @project.copy(@source_project, :only => ['members', 'issue_categories']) |
974 | 984 |
975 assert @project.members.any? | 985 assert @project.members.any? |
976 assert @project.issue_categories.any? | 986 assert @project.issue_categories.any? |
977 assert @project.issues.empty? | 987 assert @project.issues.empty? |
978 end | 988 end |
979 | 989 |
980 end | 990 end |
981 | 991 |
982 context "#start_date" do | 992 context "#start_date" do |
983 setup do | 993 setup do |
984 ProjectCustomField.destroy_all # Custom values are a mess to isolate in tests | 994 ProjectCustomField.destroy_all # Custom values are a mess to isolate in tests |
985 @project = Project.generate!(:identifier => 'test0') | 995 @project = Project.generate!(:identifier => 'test0') |
986 @project.trackers << Tracker.generate! | 996 @project.trackers << Tracker.generate! |
987 end | 997 end |
988 | 998 |
989 should "be nil if there are no issues on the project" do | 999 should "be nil if there are no issues on the project" do |
990 assert_nil @project.start_date | 1000 assert_nil @project.start_date |
991 end | 1001 end |
992 | 1002 |
993 should "be tested when issues have no start date" | 1003 should "be tested when issues have no start date" |
994 | 1004 |
995 should "be the earliest start date of it's issues" do | 1005 should "be the earliest start date of it's issues" do |
996 early = 7.days.ago.to_date | 1006 early = 7.days.ago.to_date |
997 Issue.generate_for_project!(@project, :start_date => Date.today) | 1007 Issue.generate_for_project!(@project, :start_date => Date.today) |
1006 setup do | 1016 setup do |
1007 ProjectCustomField.destroy_all # Custom values are a mess to isolate in tests | 1017 ProjectCustomField.destroy_all # Custom values are a mess to isolate in tests |
1008 @project = Project.generate!(:identifier => 'test0') | 1018 @project = Project.generate!(:identifier => 'test0') |
1009 @project.trackers << Tracker.generate! | 1019 @project.trackers << Tracker.generate! |
1010 end | 1020 end |
1011 | 1021 |
1012 should "be nil if there are no issues on the project" do | 1022 should "be nil if there are no issues on the project" do |
1013 assert_nil @project.due_date | 1023 assert_nil @project.due_date |
1014 end | 1024 end |
1015 | 1025 |
1016 should "be tested when issues have no due date" | 1026 should "be tested when issues have no due date" |
1017 | 1027 |
1018 should "be the latest due date of it's issues" do | 1028 should "be the latest due date of it's issues" do |
1019 future = 7.days.from_now.to_date | 1029 future = 7.days.from_now.to_date |
1020 Issue.generate_for_project!(@project, :due_date => future) | 1030 Issue.generate_for_project!(@project, :due_date => future) |
1025 | 1035 |
1026 should "be the latest due date of it's versions" do | 1036 should "be the latest due date of it's versions" do |
1027 future = 7.days.from_now.to_date | 1037 future = 7.days.from_now.to_date |
1028 @project.versions << Version.generate!(:effective_date => future) | 1038 @project.versions << Version.generate!(:effective_date => future) |
1029 @project.versions << Version.generate!(:effective_date => Date.today) | 1039 @project.versions << Version.generate!(:effective_date => Date.today) |
1030 | 1040 |
1031 | 1041 |
1032 assert_equal future, @project.due_date | 1042 assert_equal future, @project.due_date |
1033 | 1043 |
1034 end | 1044 end |
1035 | 1045 |
1036 should "pick the latest date from it's issues and versions" do | 1046 should "pick the latest date from it's issues and versions" do |
1037 future = 7.days.from_now.to_date | 1047 future = 7.days.from_now.to_date |
1038 far_future = 14.days.from_now.to_date | 1048 far_future = 14.days.from_now.to_date |
1039 Issue.generate_for_project!(@project, :due_date => far_future) | 1049 Issue.generate_for_project!(@project, :due_date => far_future) |
1040 @project.versions << Version.generate!(:effective_date => future) | 1050 @project.versions << Version.generate!(:effective_date => future) |
1041 | 1051 |
1042 assert_equal far_future, @project.due_date | 1052 assert_equal far_future, @project.due_date |
1043 end | 1053 end |
1044 | 1054 |
1045 end | 1055 end |
1046 | 1056 |
1088 | 1098 |
1089 context "#notified_users" do | 1099 context "#notified_users" do |
1090 setup do | 1100 setup do |
1091 @project = Project.generate! | 1101 @project = Project.generate! |
1092 @role = Role.generate! | 1102 @role = Role.generate! |
1093 | 1103 |
1094 @user_with_membership_notification = User.generate!(:mail_notification => 'selected') | 1104 @user_with_membership_notification = User.generate!(:mail_notification => 'selected') |
1095 Member.generate!(:project => @project, :roles => [@role], :principal => @user_with_membership_notification, :mail_notification => true) | 1105 Member.generate!(:project => @project, :roles => [@role], :principal => @user_with_membership_notification, :mail_notification => true) |
1096 | 1106 |
1097 @all_events_user = User.generate!(:mail_notification => 'all') | 1107 @all_events_user = User.generate!(:mail_notification => 'all') |
1098 Member.generate!(:project => @project, :roles => [@role], :principal => @all_events_user) | 1108 Member.generate!(:project => @project, :roles => [@role], :principal => @all_events_user) |
1107 Member.generate!(:project => @project, :roles => [@role], :principal => @only_assigned_user) | 1117 Member.generate!(:project => @project, :roles => [@role], :principal => @only_assigned_user) |
1108 | 1118 |
1109 @only_owned_user = User.generate!(:mail_notification => 'only_owner') | 1119 @only_owned_user = User.generate!(:mail_notification => 'only_owner') |
1110 Member.generate!(:project => @project, :roles => [@role], :principal => @only_owned_user) | 1120 Member.generate!(:project => @project, :roles => [@role], :principal => @only_owned_user) |
1111 end | 1121 end |
1112 | 1122 |
1113 should "include members with a mail notification" do | 1123 should "include members with a mail notification" do |
1114 assert @project.notified_users.include?(@user_with_membership_notification) | 1124 assert @project.notified_users.include?(@user_with_membership_notification) |
1115 end | 1125 end |
1116 | 1126 |
1117 should "include users with the 'all' notification option" do | 1127 should "include users with the 'all' notification option" do |
1118 assert @project.notified_users.include?(@all_events_user) | 1128 assert @project.notified_users.include?(@all_events_user) |
1119 end | 1129 end |
1120 | 1130 |
1121 should "not include users with the 'none' notification option" do | 1131 should "not include users with the 'none' notification option" do |
1122 assert !@project.notified_users.include?(@no_events_user) | 1132 assert !@project.notified_users.include?(@no_events_user) |
1123 end | 1133 end |
1124 | 1134 |
1125 should "not include users with the 'only_my_events' notification option" do | 1135 should "not include users with the 'only_my_events' notification option" do |
1126 assert !@project.notified_users.include?(@only_my_events_user) | 1136 assert !@project.notified_users.include?(@only_my_events_user) |
1127 end | 1137 end |
1128 | 1138 |
1129 should "not include users with the 'only_assigned' notification option" do | 1139 should "not include users with the 'only_assigned' notification option" do |
1130 assert !@project.notified_users.include?(@only_assigned_user) | 1140 assert !@project.notified_users.include?(@only_assigned_user) |
1131 end | 1141 end |
1132 | 1142 |
1133 should "not include users with the 'only_owner' notification option" do | 1143 should "not include users with the 'only_owner' notification option" do |
1134 assert !@project.notified_users.include?(@only_owned_user) | 1144 assert !@project.notified_users.include?(@only_owned_user) |
1135 end | 1145 end |
1136 end | 1146 end |
1137 | 1147 |
1138 end | 1148 end |