@@ -5,12 +5,12 | |||
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 |
# |
|
|
8 | # | |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 |
# |
|
|
13 | # | |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
@@ -25,7 +25,7 class ProjectTest < ActiveSupport::TestCase | |||
|
25 | 25 | @ecookbook_sub1 = Project.find(3) |
|
26 | 26 | User.current = nil |
|
27 | 27 | end |
|
28 | ||
|
28 | ||
|
29 | 29 | should_validate_presence_of :name |
|
30 | 30 | should_validate_presence_of :identifier |
|
31 | 31 | |
@@ -59,7 +59,7 class ProjectTest < ActiveSupport::TestCase | |||
|
59 | 59 | assert_kind_of Project, @ecookbook |
|
60 | 60 | assert_equal "eCookbook", @ecookbook.name |
|
61 | 61 | end |
|
62 | ||
|
62 | ||
|
63 | 63 | def test_default_attributes |
|
64 | 64 | with_settings :default_projects_public => '1' do |
|
65 | 65 | assert_equal true, Project.new.is_public |
@@ -84,11 +84,11 class ProjectTest < ActiveSupport::TestCase | |||
|
84 | 84 | with_settings :default_projects_modules => ['issue_tracking', 'repository'] do |
|
85 | 85 | assert_equal ['issue_tracking', 'repository'], Project.new.enabled_module_names |
|
86 | 86 | end |
|
87 | ||
|
87 | ||
|
88 | 88 | assert_equal Tracker.all, Project.new.trackers |
|
89 | 89 | assert_equal Tracker.find(1, 3), Project.new(:tracker_ids => [1, 3]).trackers |
|
90 | 90 | end |
|
91 | ||
|
91 | ||
|
92 | 92 | def test_update |
|
93 | 93 | assert_equal "eCookbook", @ecookbook.name |
|
94 | 94 | @ecookbook.name = "eCook" |
@@ -96,14 +96,14 class ProjectTest < ActiveSupport::TestCase | |||
|
96 | 96 | @ecookbook.reload |
|
97 | 97 | assert_equal "eCook", @ecookbook.name |
|
98 | 98 | end |
|
99 | ||
|
99 | ||
|
100 | 100 | def test_validate_identifier |
|
101 | 101 | to_test = {"abc" => true, |
|
102 | 102 | "ab12" => true, |
|
103 | 103 | "ab-12" => true, |
|
104 | 104 | "12" => false, |
|
105 | 105 | "new" => false} |
|
106 | ||
|
106 | ||
|
107 | 107 | to_test.each do |identifier, valid| |
|
108 | 108 | p = Project.new |
|
109 | 109 | p.identifier = identifier |
@@ -117,18 +117,18 class ProjectTest < ActiveSupport::TestCase | |||
|
117 | 117 | assert_nil project.members.detect {|m| !(m.user.is_a?(User) && m.user.active?) } |
|
118 | 118 | end |
|
119 | 119 | end |
|
120 | ||
|
120 | ||
|
121 | 121 | def test_users_should_be_active_users |
|
122 | 122 | Project.all.each do |project| |
|
123 | 123 | assert_nil project.users.detect {|u| !(u.is_a?(User) && u.active?) } |
|
124 | 124 | end |
|
125 | 125 | end |
|
126 | ||
|
126 | ||
|
127 | 127 | def test_archive |
|
128 | 128 | user = @ecookbook.members.first.user |
|
129 | 129 | @ecookbook.archive |
|
130 | 130 | @ecookbook.reload |
|
131 | ||
|
131 | ||
|
132 | 132 | assert !@ecookbook.active? |
|
133 | 133 | assert @ecookbook.archived? |
|
134 | 134 | assert !user.projects.include?(@ecookbook) |
@@ -136,24 +136,24 class ProjectTest < ActiveSupport::TestCase | |||
|
136 | 136 | assert !@ecookbook.children.empty? |
|
137 | 137 | assert @ecookbook.descendants.active.empty? |
|
138 | 138 | end |
|
139 | ||
|
139 | ||
|
140 | 140 | def test_archive_should_fail_if_versions_are_used_by_non_descendant_projects |
|
141 | 141 | # Assign an issue of a project to a version of a child project |
|
142 | 142 | Issue.find(4).update_attribute :fixed_version_id, 4 |
|
143 | ||
|
143 | ||
|
144 | 144 | assert_no_difference "Project.count(:all, :conditions => 'status = #{Project::STATUS_ARCHIVED}')" do |
|
145 | 145 | assert_equal false, @ecookbook.archive |
|
146 | 146 | end |
|
147 | 147 | @ecookbook.reload |
|
148 | 148 | assert @ecookbook.active? |
|
149 | 149 | end |
|
150 | ||
|
150 | ||
|
151 | 151 | def test_unarchive |
|
152 | 152 | user = @ecookbook.members.first.user |
|
153 | 153 | @ecookbook.archive |
|
154 | 154 | # A subproject of an archived project can not be unarchived |
|
155 | 155 | assert !@ecookbook_sub1.unarchive |
|
156 | ||
|
156 | ||
|
157 | 157 | # Unarchive project |
|
158 | 158 | assert @ecookbook.unarchive |
|
159 | 159 | @ecookbook.reload |
@@ -164,7 +164,7 class ProjectTest < ActiveSupport::TestCase | |||
|
164 | 164 | @ecookbook_sub1.reload |
|
165 | 165 | assert @ecookbook_sub1.unarchive |
|
166 | 166 | end |
|
167 | ||
|
167 | ||
|
168 | 168 | def test_destroy |
|
169 | 169 | # 2 active members |
|
170 | 170 | assert_equal 2, @ecookbook.members.size |
@@ -172,7 +172,7 class ProjectTest < ActiveSupport::TestCase | |||
|
172 | 172 | assert_equal 3, Member.find(:all, :conditions => ['project_id = ?', @ecookbook.id]).size |
|
173 | 173 | # some boards |
|
174 | 174 | assert @ecookbook.boards.any? |
|
175 | ||
|
175 | ||
|
176 | 176 | @ecookbook.destroy |
|
177 | 177 | # make sure that the project non longer exists |
|
178 | 178 | assert_raise(ActiveRecord::RecordNotFound) { Project.find(@ecookbook.id) } |
@@ -181,12 +181,12 class ProjectTest < ActiveSupport::TestCase | |||
|
181 | 181 | assert_nil Board.first(:conditions => {:project_id => @ecookbook.id}) |
|
182 | 182 | assert_nil Issue.first(:conditions => {:project_id => @ecookbook.id}) |
|
183 | 183 | end |
|
184 | ||
|
184 | ||
|
185 | 185 | def test_destroying_root_projects_should_clear_data |
|
186 | 186 | Project.roots.each do |root| |
|
187 | 187 | root.destroy |
|
188 | 188 | end |
|
189 | ||
|
189 | ||
|
190 | 190 | assert_equal 0, Project.count, "Projects were not deleted: #{Project.all.inspect}" |
|
191 | 191 | assert_equal 0, Member.count, "Members were not deleted: #{Member.all.inspect}" |
|
192 | 192 | assert_equal 0, MemberRole.count |
@@ -216,7 +216,7 class ProjectTest < ActiveSupport::TestCase | |||
|
216 | 216 | assert_equal 0, Project.connection.select_all("SELECT * FROM custom_fields_projects").size |
|
217 | 217 | assert_equal 0, CustomValue.count(:conditions => {:customized_type => ['Project', 'Issue', 'TimeEntry', 'Version']}) |
|
218 | 218 | end |
|
219 | ||
|
219 | ||
|
220 | 220 | def test_move_an_orphan_project_to_a_root_project |
|
221 | 221 | sub = Project.find(2) |
|
222 | 222 | sub.set_parent! @ecookbook |
@@ -224,22 +224,22 class ProjectTest < ActiveSupport::TestCase | |||
|
224 | 224 | @ecookbook.reload |
|
225 | 225 | assert_equal 4, @ecookbook.children.size |
|
226 | 226 | end |
|
227 | ||
|
227 | ||
|
228 | 228 | def test_move_an_orphan_project_to_a_subproject |
|
229 | 229 | sub = Project.find(2) |
|
230 | 230 | assert sub.set_parent!(@ecookbook_sub1) |
|
231 | 231 | end |
|
232 | ||
|
232 | ||
|
233 | 233 | def test_move_a_root_project_to_a_project |
|
234 | 234 | sub = @ecookbook |
|
235 | 235 | assert sub.set_parent!(Project.find(2)) |
|
236 | 236 | end |
|
237 | ||
|
237 | ||
|
238 | 238 | def test_should_not_move_a_project_to_its_children |
|
239 | 239 | sub = @ecookbook |
|
240 | 240 | assert !(sub.set_parent!(Project.find(3))) |
|
241 | 241 | end |
|
242 | ||
|
242 | ||
|
243 | 243 | def test_set_parent_should_add_roots_in_alphabetical_order |
|
244 | 244 | ProjectCustomField.delete_all |
|
245 | 245 | Project.delete_all |
@@ -247,11 +247,11 class ProjectTest < ActiveSupport::TestCase | |||
|
247 | 247 | Project.create!(:name => 'Project B', :identifier => 'project-b').set_parent!(nil) |
|
248 | 248 | Project.create!(:name => 'Project D', :identifier => 'project-d').set_parent!(nil) |
|
249 | 249 | Project.create!(:name => 'Project A', :identifier => 'project-a').set_parent!(nil) |
|
250 | ||
|
250 | ||
|
251 | 251 | assert_equal 4, Project.count |
|
252 | 252 | assert_equal Project.all.sort_by(&:name), Project.all.sort_by(&:lft) |
|
253 | 253 | end |
|
254 | ||
|
254 | ||
|
255 | 255 | def test_set_parent_should_add_children_in_alphabetical_order |
|
256 | 256 | ProjectCustomField.delete_all |
|
257 | 257 | parent = Project.create!(:name => 'Parent', :identifier => 'parent') |
@@ -259,12 +259,12 class ProjectTest < ActiveSupport::TestCase | |||
|
259 | 259 | Project.create!(:name => 'Project B', :identifier => 'project-b').set_parent!(parent) |
|
260 | 260 | Project.create!(:name => 'Project D', :identifier => 'project-d').set_parent!(parent) |
|
261 | 261 | Project.create!(:name => 'Project A', :identifier => 'project-a').set_parent!(parent) |
|
262 | ||
|
262 | ||
|
263 | 263 | parent.reload |
|
264 | 264 | assert_equal 4, parent.children.size |
|
265 | 265 | assert_equal parent.children.sort_by(&:name), parent.children |
|
266 | 266 | end |
|
267 | ||
|
267 | ||
|
268 | 268 | def test_rebuild_should_sort_children_alphabetically |
|
269 | 269 | ProjectCustomField.delete_all |
|
270 | 270 | parent = Project.create!(:name => 'Parent', :identifier => 'parent') |
@@ -272,10 +272,10 class ProjectTest < ActiveSupport::TestCase | |||
|
272 | 272 | Project.create!(:name => 'Project B', :identifier => 'project-b').move_to_child_of(parent) |
|
273 | 273 | Project.create!(:name => 'Project D', :identifier => 'project-d').move_to_child_of(parent) |
|
274 | 274 | Project.create!(:name => 'Project A', :identifier => 'project-a').move_to_child_of(parent) |
|
275 | ||
|
275 | ||
|
276 | 276 | Project.update_all("lft = NULL, rgt = NULL") |
|
277 | 277 | Project.rebuild! |
|
278 | ||
|
278 | ||
|
279 | 279 | parent.reload |
|
280 | 280 | assert_equal 4, parent.children.size |
|
281 | 281 | assert_equal parent.children.sort_by(&:name), parent.children |
@@ -300,49 +300,49 class ProjectTest < ActiveSupport::TestCase | |||
|
300 | 300 | issue_with_hierarchy_fixed_version.update_attribute(:fixed_version_id, 6) |
|
301 | 301 | issue_with_hierarchy_fixed_version.reload |
|
302 | 302 | assert_equal 6, issue_with_hierarchy_fixed_version.fixed_version_id |
|
303 | ||
|
303 | ||
|
304 | 304 | # Move project out of the issue's hierarchy |
|
305 | 305 | moved_project = Project.find(3) |
|
306 | 306 | moved_project.set_parent!(Project.find(2)) |
|
307 | 307 | parent_issue.reload |
|
308 | 308 | issue_with_local_fixed_version.reload |
|
309 | 309 | issue_with_hierarchy_fixed_version.reload |
|
310 | ||
|
310 | ||
|
311 | 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" |
|
312 | 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" |
|
313 | 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." |
|
314 | 314 | end |
|
315 | ||
|
315 | ||
|
316 | 316 | def test_parent |
|
317 | 317 | p = Project.find(6).parent |
|
318 | 318 | assert p.is_a?(Project) |
|
319 | 319 | assert_equal 5, p.id |
|
320 | 320 | end |
|
321 | ||
|
321 | ||
|
322 | 322 | def test_ancestors |
|
323 | 323 | a = Project.find(6).ancestors |
|
324 | 324 | assert a.first.is_a?(Project) |
|
325 | 325 | assert_equal [1, 5], a.collect(&:id) |
|
326 | 326 | end |
|
327 | ||
|
327 | ||
|
328 | 328 | def test_root |
|
329 | 329 | r = Project.find(6).root |
|
330 | 330 | assert r.is_a?(Project) |
|
331 | 331 | assert_equal 1, r.id |
|
332 | 332 | end |
|
333 | ||
|
333 | ||
|
334 | 334 | def test_children |
|
335 | 335 | c = Project.find(1).children |
|
336 | 336 | assert c.first.is_a?(Project) |
|
337 | 337 | assert_equal [5, 3, 4], c.collect(&:id) |
|
338 | 338 | end |
|
339 | ||
|
339 | ||
|
340 | 340 | def test_descendants |
|
341 | 341 | d = Project.find(1).descendants |
|
342 | 342 | assert d.first.is_a?(Project) |
|
343 | 343 | assert_equal [5, 6, 3, 4], d.collect(&:id) |
|
344 | 344 | end |
|
345 | ||
|
345 | ||
|
346 | 346 | def test_allowed_parents_should_be_empty_for_non_member_user |
|
347 | 347 | Role.non_member.add_permission!(:add_project) |
|
348 | 348 | user = User.find(9) |
@@ -350,7 +350,7 class ProjectTest < ActiveSupport::TestCase | |||
|
350 | 350 | User.current = user |
|
351 | 351 | assert Project.new.allowed_parents.compact.empty? |
|
352 | 352 | end |
|
353 | ||
|
353 | ||
|
354 | 354 | def test_allowed_parents_with_add_subprojects_permission |
|
355 | 355 | Role.find(1).remove_permission!(:add_project) |
|
356 | 356 | Role.find(1).add_permission!(:add_subprojects) |
@@ -392,7 +392,7 class ProjectTest < ActiveSupport::TestCase | |||
|
392 | 392 | assert Project.find(3).allowed_parents.include?(Project.find(1)) |
|
393 | 393 | assert Project.find(3).allowed_parents.include?(nil) |
|
394 | 394 | end |
|
395 | ||
|
395 | ||
|
396 | 396 | def test_users_by_role |
|
397 | 397 | users_by_role = Project.find(1).users_by_role |
|
398 | 398 | assert_kind_of Hash, users_by_role |
@@ -400,29 +400,29 class ProjectTest < ActiveSupport::TestCase | |||
|
400 | 400 | assert_kind_of Array, users_by_role[role] |
|
401 | 401 | assert users_by_role[role].include?(User.find(2)) |
|
402 | 402 | end |
|
403 | ||
|
403 | ||
|
404 | 404 | def test_rolled_up_trackers |
|
405 | 405 | parent = Project.find(1) |
|
406 | 406 | parent.trackers = Tracker.find([1,2]) |
|
407 | 407 | child = parent.children.find(3) |
|
408 | ||
|
408 | ||
|
409 | 409 | assert_equal [1, 2], parent.tracker_ids |
|
410 | 410 | assert_equal [2, 3], child.trackers.collect(&:id) |
|
411 | ||
|
411 | ||
|
412 | 412 | assert_kind_of Tracker, parent.rolled_up_trackers.first |
|
413 | 413 | assert_equal Tracker.find(1), parent.rolled_up_trackers.first |
|
414 | ||
|
414 | ||
|
415 | 415 | assert_equal [1, 2, 3], parent.rolled_up_trackers.collect(&:id) |
|
416 | 416 | assert_equal [2, 3], child.rolled_up_trackers.collect(&:id) |
|
417 | 417 | end |
|
418 | ||
|
418 | ||
|
419 | 419 | def test_rolled_up_trackers_should_ignore_archived_subprojects |
|
420 | 420 | parent = Project.find(1) |
|
421 | 421 | parent.trackers = Tracker.find([1,2]) |
|
422 | 422 | child = parent.children.find(3) |
|
423 | 423 | child.trackers = Tracker.find([1,3]) |
|
424 | 424 | parent.children.each(&:archive) |
|
425 | ||
|
425 | ||
|
426 | 426 | assert_equal [1,2], parent.rolled_up_trackers.collect(&:id) |
|
427 | 427 | end |
|
428 | 428 | |
@@ -432,11 +432,11 class ProjectTest < ActiveSupport::TestCase | |||
|
432 | 432 | @parent_version_1 = Version.generate!(:project => @project) |
|
433 | 433 | @parent_version_2 = Version.generate!(:project => @project) |
|
434 | 434 | end |
|
435 | ||
|
435 | ||
|
436 | 436 | should "include the versions for the current project" do |
|
437 | 437 | assert_same_elements [@parent_version_1, @parent_version_2], @project.rolled_up_versions |
|
438 | 438 | end |
|
439 | ||
|
439 | ||
|
440 | 440 | should "include versions for a subproject" do |
|
441 | 441 | @subproject = Project.generate! |
|
442 | 442 | @subproject.set_parent!(@project) |
@@ -448,7 +448,7 class ProjectTest < ActiveSupport::TestCase | |||
|
448 | 448 | @subproject_version |
|
449 | 449 | ], @project.rolled_up_versions |
|
450 | 450 | end |
|
451 | ||
|
451 | ||
|
452 | 452 | should "include versions for a sub-subproject" do |
|
453 | 453 | @subproject = Project.generate! |
|
454 | 454 | @subproject.set_parent!(@project) |
@@ -465,7 +465,6 class ProjectTest < ActiveSupport::TestCase | |||
|
465 | 465 | ], @project.rolled_up_versions |
|
466 | 466 | end |
|
467 | 467 | |
|
468 | ||
|
469 | 468 | should "only check active projects" do |
|
470 | 469 | @subproject = Project.generate! |
|
471 | 470 | @subproject.set_parent!(@project) |
@@ -478,7 +477,7 class ProjectTest < ActiveSupport::TestCase | |||
|
478 | 477 | assert_same_elements [@parent_version_1, @parent_version_2], @project.rolled_up_versions |
|
479 | 478 | end |
|
480 | 479 | end |
|
481 | ||
|
480 | ||
|
482 | 481 | def test_shared_versions_none_sharing |
|
483 | 482 | p = Project.find(5) |
|
484 | 483 | v = Version.create!(:name => 'none_sharing', :project => p, :sharing => 'none') |
@@ -498,7 +497,7 class ProjectTest < ActiveSupport::TestCase | |||
|
498 | 497 | assert !p.siblings.first.shared_versions.include?(v) |
|
499 | 498 | assert !p.root.siblings.first.shared_versions.include?(v) |
|
500 | 499 | end |
|
501 | ||
|
500 | ||
|
502 | 501 | def test_shared_versions_hierarchy_sharing |
|
503 | 502 | p = Project.find(5) |
|
504 | 503 | v = Version.create!(:name => 'hierarchy_sharing', :project => p, :sharing => 'hierarchy') |
@@ -533,7 +532,7 class ProjectTest < ActiveSupport::TestCase | |||
|
533 | 532 | parent = Project.find(1) |
|
534 | 533 | child = parent.children.find(3) |
|
535 | 534 | private_child = parent.children.find(5) |
|
536 | ||
|
535 | ||
|
537 | 536 | assert_equal [1,2,3], parent.version_ids.sort |
|
538 | 537 | assert_equal [4], child.version_ids |
|
539 | 538 | assert_equal [6], private_child.version_ids |
@@ -552,7 +551,7 class ProjectTest < ActiveSupport::TestCase | |||
|
552 | 551 | child = parent.children.find(3) |
|
553 | 552 | child.archive |
|
554 | 553 | parent.reload |
|
555 | ||
|
554 | ||
|
556 | 555 | assert_equal [1,2,3], parent.version_ids.sort |
|
557 | 556 | assert_equal [4], child.version_ids |
|
558 | 557 | assert !parent.shared_versions.collect(&:id).include?(4) |
@@ -562,12 +561,12 class ProjectTest < ActiveSupport::TestCase | |||
|
562 | 561 | user = User.find(3) |
|
563 | 562 | parent = Project.find(1) |
|
564 | 563 | child = parent.children.find(5) |
|
565 | ||
|
564 | ||
|
566 | 565 | assert_equal [1,2,3], parent.version_ids.sort |
|
567 | 566 | assert_equal [6], child.version_ids |
|
568 | 567 | |
|
569 | 568 | versions = parent.shared_versions.visible(user) |
|
570 | ||
|
569 | ||
|
571 | 570 | assert_equal 4, versions.size |
|
572 | 571 | versions.each do |version| |
|
573 | 572 | assert_kind_of Version, version |
@@ -576,7 +575,6 class ProjectTest < ActiveSupport::TestCase | |||
|
576 | 575 | assert !versions.collect(&:id).include?(6) |
|
577 | 576 | end |
|
578 | 577 | |
|
579 | ||
|
580 | 578 | def test_next_identifier |
|
581 | 579 | ProjectCustomField.delete_all |
|
582 | 580 | Project.create!(:name => 'last', :identifier => 'p2008040') |
@@ -587,11 +585,11 class ProjectTest < ActiveSupport::TestCase | |||
|
587 | 585 | Project.delete_all |
|
588 | 586 | assert_nil Project.next_identifier |
|
589 | 587 | end |
|
590 | ||
|
588 | ||
|
591 | 589 | def test_enabled_module_names |
|
592 | 590 | with_settings :default_projects_modules => ['issue_tracking', 'repository'] do |
|
593 | 591 | project = Project.new |
|
594 | ||
|
592 | ||
|
595 | 593 | project.enabled_module_names = %w(issue_tracking news) |
|
596 | 594 | assert_equal %w(issue_tracking news), project.enabled_module_names.sort |
|
597 | 595 | end |
@@ -667,7 +665,7 class ProjectTest < ActiveSupport::TestCase | |||
|
667 | 665 | assert copied_project.id.blank? |
|
668 | 666 | assert copied_project.name.blank? |
|
669 | 667 | assert copied_project.identifier.blank? |
|
670 | ||
|
668 | ||
|
671 | 669 | # Duplicated attributes |
|
672 | 670 | assert_equal source_project.description, copied_project.description |
|
673 | 671 | assert_equal source_project.enabled_modules, copied_project.enabled_modules |
@@ -745,11 +743,11 class ProjectTest < ActiveSupport::TestCase | |||
|
745 | 743 | assert system_activity.active? |
|
746 | 744 | overridden_activity = TimeEntryActivity.generate!(:project => project, :parent => system_activity, :active => false) |
|
747 | 745 | assert overridden_activity.save! |
|
748 | ||
|
746 | ||
|
749 | 747 | assert !project.activities.include?(overridden_activity), "Inactive Project specific Activity not found" |
|
750 | 748 | assert !project.activities.include?(system_activity), "System activity found when the project has an inactive override" |
|
751 | 749 | end |
|
752 | ||
|
750 | ||
|
753 | 751 | def test_close_completed_versions |
|
754 | 752 | Version.update_all("status = 'open'") |
|
755 | 753 | project = Project.find(1) |
@@ -787,7 +785,7 class ProjectTest < ActiveSupport::TestCase | |||
|
787 | 785 | assert ! issue.assigned_to.blank? |
|
788 | 786 | assert_equal @project, issue.project |
|
789 | 787 | end |
|
790 | ||
|
788 | ||
|
791 | 789 | copied_issue = @project.issues.first(:conditions => {:subject => "copy issue status"}) |
|
792 | 790 | assert copied_issue |
|
793 | 791 | assert copied_issue.status |
@@ -804,7 +802,7 class ProjectTest < ActiveSupport::TestCase | |||
|
804 | 802 | :subject => "change the new issues to use the copied version", |
|
805 | 803 | :tracker_id => 1, |
|
806 | 804 | :project_id => @source_project.id) |
|
807 | ||
|
805 | ||
|
808 | 806 | assert @project.copy(@source_project) |
|
809 | 807 | @project.reload |
|
810 | 808 | copied_issue = @project.issues.first(:conditions => {:subject => "change the new issues to use the copied version"}) |
@@ -861,10 +859,10 class ProjectTest < ActiveSupport::TestCase | |||
|
861 | 859 | assert_equal @project, membership.project |
|
862 | 860 | end |
|
863 | 861 | end |
|
864 | ||
|
862 | ||
|
865 | 863 | should "copy memberships with groups and additional roles" do |
|
866 | 864 | group = Group.create!(:lastname => "Copy group") |
|
867 |
user = User.find(7) |
|
|
865 | user = User.find(7) | |
|
868 | 866 | group.users << user |
|
869 | 867 | # group role |
|
870 | 868 | Member.create!(:project_id => @source_project.id, :principal => group, :role_ids => [2]) |
@@ -918,7 +916,7 class ProjectTest < ActiveSupport::TestCase | |||
|
918 | 916 | assert_difference 'WikiPage.count', @source_project.wiki.pages.size do |
|
919 | 917 | assert @project.copy(@source_project) |
|
920 | 918 | end |
|
921 | ||
|
919 | ||
|
922 | 920 | assert @project.wiki |
|
923 | 921 | assert_equal @source_project.wiki.pages.size, @project.wiki.pages.size |
|
924 | 922 | |
@@ -926,7 +924,7 class ProjectTest < ActiveSupport::TestCase | |||
|
926 | 924 | assert wiki_page.content |
|
927 | 925 | assert !@source_project.wiki.pages.include?(wiki_page) |
|
928 | 926 | end |
|
929 | ||
|
927 | ||
|
930 | 928 | parent = @project.wiki.find_page('Parent_page') |
|
931 | 929 | child1 = @project.wiki.find_page('Child_page_1') |
|
932 | 930 | child2 = @project.wiki.find_page('Child_page_2') |
@@ -964,19 +962,19 class ProjectTest < ActiveSupport::TestCase | |||
|
964 | 962 | assert_not_equal IssueCategory.find(3), issue.category # Different record |
|
965 | 963 | end |
|
966 | 964 | end |
|
967 | ||
|
965 | ||
|
968 | 966 | should "limit copy with :only option" do |
|
969 | 967 | assert @project.members.empty? |
|
970 | 968 | assert @project.issue_categories.empty? |
|
971 | 969 | assert @source_project.issues.any? |
|
972 | ||
|
970 | ||
|
973 | 971 | assert @project.copy(@source_project, :only => ['members', 'issue_categories']) |
|
974 | 972 | |
|
975 | 973 | assert @project.members.any? |
|
976 | 974 | assert @project.issue_categories.any? |
|
977 | 975 | assert @project.issues.empty? |
|
978 | 976 | end |
|
979 | ||
|
977 | ||
|
980 | 978 | end |
|
981 | 979 | |
|
982 | 980 | context "#start_date" do |
@@ -985,11 +983,11 class ProjectTest < ActiveSupport::TestCase | |||
|
985 | 983 | @project = Project.generate!(:identifier => 'test0') |
|
986 | 984 | @project.trackers << Tracker.generate! |
|
987 | 985 | end |
|
988 | ||
|
986 | ||
|
989 | 987 | should "be nil if there are no issues on the project" do |
|
990 | 988 | assert_nil @project.start_date |
|
991 | 989 | end |
|
992 | ||
|
990 | ||
|
993 | 991 | should "be tested when issues have no start date" |
|
994 | 992 | |
|
995 | 993 | should "be the earliest start date of it's issues" do |
@@ -1008,11 +1006,11 class ProjectTest < ActiveSupport::TestCase | |||
|
1008 | 1006 | @project = Project.generate!(:identifier => 'test0') |
|
1009 | 1007 | @project.trackers << Tracker.generate! |
|
1010 | 1008 | end |
|
1011 | ||
|
1009 | ||
|
1012 | 1010 | should "be nil if there are no issues on the project" do |
|
1013 | 1011 | assert_nil @project.due_date |
|
1014 | 1012 | end |
|
1015 | ||
|
1013 | ||
|
1016 | 1014 | should "be tested when issues have no due date" |
|
1017 | 1015 | |
|
1018 | 1016 | should "be the latest due date of it's issues" do |
@@ -1027,7 +1025,7 class ProjectTest < ActiveSupport::TestCase | |||
|
1027 | 1025 | future = 7.days.from_now.to_date |
|
1028 | 1026 | @project.versions << Version.generate!(:effective_date => future) |
|
1029 | 1027 | @project.versions << Version.generate!(:effective_date => Date.today) |
|
1030 | ||
|
1028 | ||
|
1031 | 1029 | |
|
1032 | 1030 | assert_equal future, @project.due_date |
|
1033 | 1031 | |
@@ -1038,7 +1036,7 class ProjectTest < ActiveSupport::TestCase | |||
|
1038 | 1036 | far_future = 14.days.from_now.to_date |
|
1039 | 1037 | Issue.generate_for_project!(@project, :due_date => far_future) |
|
1040 | 1038 | @project.versions << Version.generate!(:effective_date => future) |
|
1041 | ||
|
1039 | ||
|
1042 | 1040 | assert_equal far_future, @project.due_date |
|
1043 | 1041 | end |
|
1044 | 1042 | |
@@ -1090,7 +1088,7 class ProjectTest < ActiveSupport::TestCase | |||
|
1090 | 1088 | setup do |
|
1091 | 1089 | @project = Project.generate! |
|
1092 | 1090 | @role = Role.generate! |
|
1093 | ||
|
1091 | ||
|
1094 | 1092 | @user_with_membership_notification = User.generate!(:mail_notification => 'selected') |
|
1095 | 1093 | Member.generate!(:project => @project, :roles => [@role], :principal => @user_with_membership_notification, :mail_notification => true) |
|
1096 | 1094 | |
@@ -1109,30 +1107,30 class ProjectTest < ActiveSupport::TestCase | |||
|
1109 | 1107 | @only_owned_user = User.generate!(:mail_notification => 'only_owner') |
|
1110 | 1108 | Member.generate!(:project => @project, :roles => [@role], :principal => @only_owned_user) |
|
1111 | 1109 | end |
|
1112 | ||
|
1110 | ||
|
1113 | 1111 | should "include members with a mail notification" do |
|
1114 | 1112 | assert @project.notified_users.include?(@user_with_membership_notification) |
|
1115 | 1113 | end |
|
1116 | ||
|
1114 | ||
|
1117 | 1115 | should "include users with the 'all' notification option" do |
|
1118 | 1116 | assert @project.notified_users.include?(@all_events_user) |
|
1119 | 1117 | end |
|
1120 | ||
|
1118 | ||
|
1121 | 1119 | should "not include users with the 'none' notification option" do |
|
1122 | 1120 | assert !@project.notified_users.include?(@no_events_user) |
|
1123 | 1121 | end |
|
1124 | ||
|
1122 | ||
|
1125 | 1123 | should "not include users with the 'only_my_events' notification option" do |
|
1126 | 1124 | assert !@project.notified_users.include?(@only_my_events_user) |
|
1127 | 1125 | end |
|
1128 | ||
|
1126 | ||
|
1129 | 1127 | should "not include users with the 'only_assigned' notification option" do |
|
1130 | 1128 | assert !@project.notified_users.include?(@only_assigned_user) |
|
1131 | 1129 | end |
|
1132 | ||
|
1130 | ||
|
1133 | 1131 | should "not include users with the 'only_owner' notification option" do |
|
1134 | 1132 | assert !@project.notified_users.include?(@only_owned_user) |
|
1135 | 1133 | end |
|
1136 | 1134 | end |
|
1137 | ||
|
1135 | ||
|
1138 | 1136 | end |
General Comments 0
You need to be logged in to leave comments.
Login now