GITSCM: Tweaked git scm view layout
[gitredmine.git] / test / unit / issue_test.rb
blob5ddd4bde4bd39c0b0b6873477352e96b85bf6730
1 # redMine - project management software
2 # Copyright (C) 2006-2007  Jean-Philippe Lang
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13
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
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18 require File.dirname(__FILE__) + '/../test_helper'
20 class IssueTest < Test::Unit::TestCase
21   fixtures :projects, :users, :members, :trackers, :issue_statuses, :issue_categories, :enumerations, :issues, :custom_fields, :custom_values
23   def test_category_based_assignment
24     issue = Issue.create(:project_id => 1, :tracker_id => 1, :author_id => 3, :status_id => 1, :priority => Enumeration.get_values('IPRI').first, :subject => 'Assignment test', :description => 'Assignment test', :category_id => 1)
25     assert_equal IssueCategory.find(1).assigned_to, issue.assigned_to
26   end
27   
28   def test_copy
29     issue = Issue.new.copy_from(1)
30     assert issue.save
31     issue.reload
32     orig = Issue.find(1)
33     assert_equal orig.subject, issue.subject
34     assert_equal orig.tracker, issue.tracker
35     assert_equal orig.custom_values.first.value, issue.custom_values.first.value
36   end
37   
38   def test_close_duplicates
39     # Create 3 issues
40     issue1 = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :priority => Enumeration.get_values('IPRI').first, :subject => 'Duplicates test', :description => 'Duplicates test')
41     assert issue1.save
42     issue2 = issue1.clone
43     assert issue2.save
44     issue3 = issue1.clone
45     assert issue3.save
46     
47     # 2 is a dupe of 1
48     IssueRelation.create(:issue_from => issue1, :issue_to => issue2, :relation_type => IssueRelation::TYPE_DUPLICATES)
49     # And 3 is a dupe of 2
50     IssueRelation.create(:issue_from => issue2, :issue_to => issue3, :relation_type => IssueRelation::TYPE_DUPLICATES)
51     
52     assert issue1.reload.duplicates.include?(issue2)
53     
54     # Closing issue 1
55     issue1.init_journal(User.find(:first), "Closing issue1")
56     issue1.status = IssueStatus.find :first, :conditions => {:is_closed => true}
57     assert issue1.save
58     # 2 and 3 should be also closed
59     assert issue2.reload.closed?
60     assert issue3.reload.closed?    
61   end
62 end