Mercurial > hg > soundsoftware-site
comparison test/unit/issue_nested_set_test.rb @ 1298:4f746d8966dd redmine_2.3_integration
Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:28:30 +0100 |
parents | 622f24f53b42 |
children |
comparison
equal
deleted
inserted
replaced
1297:0a574315af3e | 1298:4f746d8966dd |
---|---|
1 # Redmine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2012 Jean-Philippe Lang | 2 # Copyright (C) 2006-2013 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. |
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 IssueNestedSetTest < ActiveSupport::TestCase | 20 class IssueNestedSetTest < ActiveSupport::TestCase |
21 fixtures :projects, :users, :members, :member_roles, :roles, | 21 fixtures :projects, :users, :roles, |
22 :trackers, :projects_trackers, | 22 :trackers, :projects_trackers, |
23 :versions, | 23 :issue_statuses, :issue_categories, :issue_relations, |
24 :issue_statuses, :issue_categories, :issue_relations, :workflows, | |
25 :enumerations, | 24 :enumerations, |
26 :issues, | 25 :issues |
27 :custom_fields, :custom_fields_projects, :custom_fields_trackers, :custom_values, | |
28 :time_entries | |
29 | 26 |
30 def test_create_root_issue | 27 def test_create_root_issue |
31 issue1 = Issue.generate! | 28 issue1 = Issue.generate! |
32 issue2 = Issue.generate! | 29 issue2 = Issue.generate! |
33 issue1.reload | 30 issue1.reload |
165 | 162 |
166 child.reload | 163 child.reload |
167 child.parent_issue_id = grandchild.id | 164 child.parent_issue_id = grandchild.id |
168 assert !child.save | 165 assert !child.save |
169 assert_not_nil child.errors[:parent_issue_id] | 166 assert_not_nil child.errors[:parent_issue_id] |
170 end | |
171 | |
172 def test_moving_an_issue_should_keep_valid_relations_only | |
173 issue1 = Issue.generate! | |
174 issue2 = Issue.generate! | |
175 issue3 = Issue.generate!(:parent_issue_id => issue2.id) | |
176 issue4 = Issue.generate! | |
177 r1 = IssueRelation.create!(:issue_from => issue1, :issue_to => issue2, :relation_type => IssueRelation::TYPE_PRECEDES) | |
178 r2 = IssueRelation.create!(:issue_from => issue1, :issue_to => issue3, :relation_type => IssueRelation::TYPE_PRECEDES) | |
179 r3 = IssueRelation.create!(:issue_from => issue2, :issue_to => issue4, :relation_type => IssueRelation::TYPE_PRECEDES) | |
180 issue2.reload | |
181 issue2.parent_issue_id = issue1.id | |
182 issue2.save! | |
183 assert !IssueRelation.exists?(r1.id) | |
184 assert !IssueRelation.exists?(r2.id) | |
185 assert IssueRelation.exists?(r3.id) | |
186 end | 167 end |
187 | 168 |
188 def test_destroy_should_destroy_children | 169 def test_destroy_should_destroy_children |
189 issue1 = Issue.generate! | 170 issue1 = Issue.generate! |
190 issue2 = Issue.generate! | 171 issue2 = Issue.generate! |
365 c = Project.new(:name => 'Copy', :identifier => 'copy', :tracker_ids => [1, 2]) | 346 c = Project.new(:name => 'Copy', :identifier => 'copy', :tracker_ids => [1, 2]) |
366 c.copy(p, :only => 'issues') | 347 c.copy(p, :only => 'issues') |
367 c.reload | 348 c.reload |
368 | 349 |
369 assert_equal 5, c.issues.count | 350 assert_equal 5, c.issues.count |
370 ic1, ic2, ic3, ic4, ic5 = c.issues.find(:all, :order => 'subject') | 351 ic1, ic2, ic3, ic4, ic5 = c.issues.order('subject').all |
371 assert ic1.root? | 352 assert ic1.root? |
372 assert_equal ic1, ic2.parent | 353 assert_equal ic1, ic2.parent |
373 assert_equal ic1, ic3.parent | 354 assert_equal ic1, ic3.parent |
374 assert_equal ic2, ic4.parent | 355 assert_equal ic2, ic4.parent |
375 assert ic5.root? | 356 assert ic5.root? |