Mercurial > hg > soundsoftware-site
comparison test/unit/issue_relation_test.rb @ 524:1248a47e81b3 feature_36
Merge from branch "luisf"
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Mon, 25 Jul 2011 14:39:38 +0100 |
parents | 0c939c159af4 |
children | cbb26bc654de |
comparison
equal
deleted
inserted
replaced
519:3be6bc3c2a17 | 524:1248a47e81b3 |
---|---|
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.dirname(__FILE__) + '/../test_helper' | 18 require File.expand_path('../../test_helper', __FILE__) |
19 | 19 |
20 class IssueRelationTest < ActiveSupport::TestCase | 20 class IssueRelationTest < ActiveSupport::TestCase |
21 fixtures :issue_relations, :issues | 21 fixtures :issue_relations, :issues |
22 | 22 |
23 def test_create | 23 def test_create |
42 assert_equal IssueRelation::TYPE_PRECEDES, relation.relation_type | 42 assert_equal IssueRelation::TYPE_PRECEDES, relation.relation_type |
43 assert_equal to, relation.issue_from | 43 assert_equal to, relation.issue_from |
44 assert_equal from, relation.issue_to | 44 assert_equal from, relation.issue_to |
45 end | 45 end |
46 | 46 |
47 # TODO : document why it shouldn't be reversed if validation fails : having | |
48 # relations reversed before the validation would allow simpler code for the | |
49 # validation | |
47 def test_follows_relation_should_not_be_reversed_if_validation_fails | 50 def test_follows_relation_should_not_be_reversed_if_validation_fails |
48 from = Issue.find(1) | 51 from = Issue.find(1) |
49 to = Issue.find(2) | 52 to = Issue.find(2) |
50 | 53 |
51 relation = IssueRelation.new :issue_from => from, :issue_to => to, :relation_type => IssueRelation::TYPE_FOLLOWS, :delay => 'xx' | 54 relation = IssueRelation.new :issue_from => from, :issue_to => to, :relation_type => IssueRelation::TYPE_FOLLOWS, :delay => 'xx' |
61 | 64 |
62 relation = IssueRelation.new :issue_from => from, :issue_to => to, :relation_type => IssueRelation::TYPE_PRECEDES | 65 relation = IssueRelation.new :issue_from => from, :issue_to => to, :relation_type => IssueRelation::TYPE_PRECEDES |
63 assert_equal IssueRelation::TYPE_PRECEDES, relation.relation_type_for(from) | 66 assert_equal IssueRelation::TYPE_PRECEDES, relation.relation_type_for(from) |
64 assert_equal IssueRelation::TYPE_FOLLOWS, relation.relation_type_for(to) | 67 assert_equal IssueRelation::TYPE_FOLLOWS, relation.relation_type_for(to) |
65 end | 68 end |
69 | |
70 def test_set_issue_to_dates_without_issue_to | |
71 r = IssueRelation.new(:issue_from => Issue.new(:start_date => Date.today), :relation_type => IssueRelation::TYPE_PRECEDES, :delay => 1) | |
72 assert_nil r.set_issue_to_dates | |
73 end | |
74 | |
75 def test_set_issue_to_dates_without_issues | |
76 r = IssueRelation.new(:relation_type => IssueRelation::TYPE_PRECEDES, :delay => 1) | |
77 assert_nil r.set_issue_to_dates | |
78 end | |
79 | |
80 def test_validates_circular_dependency | |
81 IssueRelation.delete_all | |
82 assert IssueRelation.create!(:issue_from => Issue.find(1), :issue_to => Issue.find(2), :relation_type => IssueRelation::TYPE_PRECEDES) | |
83 assert IssueRelation.create!(:issue_from => Issue.find(2), :issue_to => Issue.find(3), :relation_type => IssueRelation::TYPE_PRECEDES) | |
84 r = IssueRelation.new(:issue_from => Issue.find(3), :issue_to => Issue.find(1), :relation_type => IssueRelation::TYPE_PRECEDES) | |
85 assert !r.save | |
86 assert_not_nil r.errors.on(:base) | |
87 end | |
88 | |
89 def test_validates_circular_dependency_on_reverse_relations | |
90 IssueRelation.delete_all | |
91 assert IssueRelation.create!(:issue_from => Issue.find(1), :issue_to => Issue.find(3), :relation_type => IssueRelation::TYPE_BLOCKS) | |
92 assert IssueRelation.create!(:issue_from => Issue.find(1), :issue_to => Issue.find(2), :relation_type => IssueRelation::TYPE_BLOCKED) | |
93 r = IssueRelation.new(:issue_from => Issue.find(2), :issue_to => Issue.find(1), :relation_type => IssueRelation::TYPE_BLOCKED) | |
94 assert !r.save | |
95 assert_not_nil r.errors.on(:base) | |
96 end | |
66 end | 97 end |