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.
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.
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
29 issue = Issue.new.copy_from(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
38 def test_close_duplicates
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')
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)
52 assert issue1.reload.duplicates.include?(issue2)
55 issue1.init_journal(User.find(:first), "Closing issue1")
56 issue1.status = IssueStatus.find :first, :conditions => {:is_closed => true}
58 # 2 and 3 should be also closed
59 assert issue2.reload.closed?
60 assert issue3.reload.closed?