comparison test/unit/.svn/text-base/issue_test.rb.svn-base @ 245:051f544170fe

* Update to SVN trunk revision 4993
author Chris Cannam
date Thu, 03 Mar 2011 11:42:28 +0000
parents 07fa8a8b56a8
children cbce1fd3b1b7
comparison
equal deleted inserted replaced
244:8972b600f4fb 245:051f544170fe
1 # redMine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang 2 # Copyright (C) 2006-2011 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.
208 def test_category_based_assignment 208 def test_category_based_assignment
209 issue = Issue.create(:project_id => 1, :tracker_id => 1, :author_id => 3, :status_id => 1, :priority => IssuePriority.all.first, :subject => 'Assignment test', :description => 'Assignment test', :category_id => 1) 209 issue = Issue.create(:project_id => 1, :tracker_id => 1, :author_id => 3, :status_id => 1, :priority => IssuePriority.all.first, :subject => 'Assignment test', :description => 'Assignment test', :category_id => 1)
210 assert_equal IssueCategory.find(1).assigned_to, issue.assigned_to 210 assert_equal IssueCategory.find(1).assigned_to, issue.assigned_to
211 end 211 end
212 212
213
214
215 def test_new_statuses_allowed_to
216 Workflow.delete_all
217
218 Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 2, :author => false, :assignee => false)
219 Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 3, :author => true, :assignee => false)
220 Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 4, :author => false, :assignee => true)
221 Workflow.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 5, :author => true, :assignee => true)
222 status = IssueStatus.find(1)
223 role = Role.find(1)
224 tracker = Tracker.find(1)
225 user = User.find(2)
226
227 issue = Issue.generate!(:tracker => tracker, :status => status, :project_id => 1)
228 assert_equal [1, 2], issue.new_statuses_allowed_to(user).map(&:id)
229
230 issue = Issue.generate!(:tracker => tracker, :status => status, :project_id => 1, :author => user)
231 assert_equal [1, 2, 3], issue.new_statuses_allowed_to(user).map(&:id)
232
233 issue = Issue.generate!(:tracker => tracker, :status => status, :project_id => 1, :assigned_to => user)
234 assert_equal [1, 2, 4], issue.new_statuses_allowed_to(user).map(&:id)
235
236 issue = Issue.generate!(:tracker => tracker, :status => status, :project_id => 1, :author => user, :assigned_to => user)
237 assert_equal [1, 2, 3, 4, 5], issue.new_statuses_allowed_to(user).map(&:id)
238 end
239
213 def test_copy 240 def test_copy
214 issue = Issue.new.copy_from(1) 241 issue = Issue.new.copy_from(1)
215 assert issue.save 242 assert issue.save
216 issue.reload 243 issue.reload
217 orig = Issue.find(1) 244 orig = Issue.find(1)
592 stale.save 619 stale.save
593 end 620 end
594 assert ActionMailer::Base.deliveries.empty? 621 assert ActionMailer::Base.deliveries.empty?
595 end 622 end
596 623
624 def test_journalized_description
625 IssueCustomField.delete_all
626
627 i = Issue.first
628 old_description = i.description
629 new_description = "This is the new description"
630
631 i.init_journal(User.find(2))
632 i.description = new_description
633 assert_difference 'Journal.count', 1 do
634 assert_difference 'JournalDetail.count', 1 do
635 i.save!
636 end
637 end
638
639 detail = JournalDetail.first(:order => 'id DESC')
640 assert_equal i, detail.journal.journalized
641 assert_equal 'attr', detail.property
642 assert_equal 'description', detail.prop_key
643 assert_equal old_description, detail.old_value
644 assert_equal new_description, detail.value
645 end
646
597 def test_saving_twice_should_not_duplicate_journal_details 647 def test_saving_twice_should_not_duplicate_journal_details
598 i = Issue.find(:first) 648 i = Issue.find(:first)
599 i.init_journal(User.find(2), 'Some notes') 649 i.init_journal(User.find(2), 'Some notes')
600 # initial changes 650 # initial changes
601 i.subject = 'New subject' 651 i.subject = 'New subject'