annotate test/unit/issue_relation_test.rb @ 854:be557d78a11b bug_94

Close obsolete branch bug_94
author Chris Cannam
date Thu, 14 Jul 2011 12:45:24 +0100
parents 513646585e45
children af80e5618e9b
rev   line source
Chris@0 1 # Redmine - project management software
Chris@0 2 # Copyright (C) 2006-2009 Jean-Philippe Lang
Chris@0 3 #
Chris@0 4 # This program is free software; you can redistribute it and/or
Chris@0 5 # modify it under the terms of the GNU General Public License
Chris@0 6 # as published by the Free Software Foundation; either version 2
Chris@0 7 # of the License, or (at your option) any later version.
Chris@0 8 #
Chris@0 9 # This program is distributed in the hope that it will be useful,
Chris@0 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@0 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@0 12 # GNU General Public License for more details.
Chris@0 13 #
Chris@0 14 # You should have received a copy of the GNU General Public License
Chris@0 15 # along with this program; if not, write to the Free Software
Chris@0 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@0 17
Chris@0 18 require File.dirname(__FILE__) + '/../test_helper'
Chris@0 19
Chris@0 20 class IssueRelationTest < ActiveSupport::TestCase
Chris@0 21 fixtures :issue_relations, :issues
Chris@0 22
Chris@0 23 def test_create
Chris@0 24 from = Issue.find(1)
Chris@0 25 to = Issue.find(2)
Chris@0 26
Chris@0 27 relation = IssueRelation.new :issue_from => from, :issue_to => to, :relation_type => IssueRelation::TYPE_PRECEDES
Chris@0 28 assert relation.save
Chris@0 29 relation.reload
Chris@0 30 assert_equal IssueRelation::TYPE_PRECEDES, relation.relation_type
Chris@0 31 assert_equal from, relation.issue_from
Chris@0 32 assert_equal to, relation.issue_to
Chris@0 33 end
Chris@0 34
Chris@0 35 def test_follows_relation_should_be_reversed
Chris@0 36 from = Issue.find(1)
Chris@0 37 to = Issue.find(2)
Chris@0 38
Chris@0 39 relation = IssueRelation.new :issue_from => from, :issue_to => to, :relation_type => IssueRelation::TYPE_FOLLOWS
Chris@0 40 assert relation.save
Chris@0 41 relation.reload
Chris@0 42 assert_equal IssueRelation::TYPE_PRECEDES, relation.relation_type
Chris@0 43 assert_equal to, relation.issue_from
Chris@0 44 assert_equal from, relation.issue_to
Chris@0 45 end
Chris@0 46
Chris@0 47 def test_follows_relation_should_not_be_reversed_if_validation_fails
Chris@0 48 from = Issue.find(1)
Chris@0 49 to = Issue.find(2)
Chris@0 50
Chris@0 51 relation = IssueRelation.new :issue_from => from, :issue_to => to, :relation_type => IssueRelation::TYPE_FOLLOWS, :delay => 'xx'
Chris@0 52 assert !relation.save
Chris@0 53 assert_equal IssueRelation::TYPE_FOLLOWS, relation.relation_type
Chris@0 54 assert_equal from, relation.issue_from
Chris@0 55 assert_equal to, relation.issue_to
Chris@0 56 end
Chris@0 57
Chris@0 58 def test_relation_type_for
Chris@0 59 from = Issue.find(1)
Chris@0 60 to = Issue.find(2)
Chris@0 61
Chris@0 62 relation = IssueRelation.new :issue_from => from, :issue_to => to, :relation_type => IssueRelation::TYPE_PRECEDES
Chris@0 63 assert_equal IssueRelation::TYPE_PRECEDES, relation.relation_type_for(from)
Chris@0 64 assert_equal IssueRelation::TYPE_FOLLOWS, relation.relation_type_for(to)
Chris@0 65 end
Chris@0 66 end