annotate .svn/pristine/cc/ccd0c6df52e1bfff4e857e7d0c8fc8f47b679871.svn-base @ 1628:9c5f8e24dadc live tip

Quieten this cron script
author Chris Cannam
date Tue, 25 Aug 2020 11:38:49 +0100
parents 038ba2d95de8
children
rev   line source
Chris@1296 1 # Redmine - project management software
Chris@1296 2 # Copyright (C) 2006-2008 Jean-Philippe Lang
Chris@1296 3 #
Chris@1296 4 # This program is free software; you can redistribute it and/or
Chris@1296 5 # modify it under the terms of the GNU General Public License
Chris@1296 6 # as published by the Free Software Foundation; either version 2
Chris@1296 7 # of the License, or (at your option) any later version.
Chris@1296 8 #
Chris@1296 9 # This program is distributed in the hope that it will be useful,
Chris@1296 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@1296 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@1296 12 # GNU General Public License for more details.
Chris@1296 13 #
Chris@1296 14 # You should have received a copy of the GNU General Public License
Chris@1296 15 # along with this program; if not, write to the Free Software
Chris@1296 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@1296 17
Chris@1296 18 require File.expand_path('../../test_helper', __FILE__)
Chris@1296 19
Chris@1296 20 class TrackerTest < ActiveSupport::TestCase
Chris@1296 21 fixtures :trackers, :workflows, :issue_statuses, :roles, :issues
Chris@1296 22
Chris@1296 23 def test_sorted_scope
Chris@1296 24 assert_equal Tracker.all.sort, Tracker.sorted.all
Chris@1296 25 end
Chris@1296 26
Chris@1296 27 def test_named_scope
Chris@1296 28 assert_equal Tracker.find_by_name('Feature'), Tracker.named('feature').first
Chris@1296 29 end
Chris@1296 30
Chris@1296 31 def test_copy_workflows
Chris@1296 32 source = Tracker.find(1)
Chris@1296 33 assert_equal 89, source.workflow_rules.size
Chris@1296 34
Chris@1296 35 target = Tracker.new(:name => 'Target')
Chris@1296 36 assert target.save
Chris@1296 37 target.workflow_rules.copy(source)
Chris@1296 38 target.reload
Chris@1296 39 assert_equal 89, target.workflow_rules.size
Chris@1296 40 end
Chris@1296 41
Chris@1296 42 def test_issue_statuses
Chris@1296 43 tracker = Tracker.find(1)
Chris@1296 44 WorkflowTransition.delete_all
Chris@1296 45 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 2, :new_status_id => 3)
Chris@1296 46 WorkflowTransition.create!(:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 5)
Chris@1296 47
Chris@1296 48 assert_kind_of Array, tracker.issue_statuses
Chris@1296 49 assert_kind_of IssueStatus, tracker.issue_statuses.first
Chris@1296 50 assert_equal [2, 3, 5], Tracker.find(1).issue_statuses.collect(&:id)
Chris@1296 51 end
Chris@1296 52
Chris@1296 53 def test_issue_statuses_empty
Chris@1296 54 WorkflowTransition.delete_all("tracker_id = 1")
Chris@1296 55 assert_equal [], Tracker.find(1).issue_statuses
Chris@1296 56 end
Chris@1296 57
Chris@1296 58 def test_issue_statuses_should_be_empty_for_new_record
Chris@1296 59 assert_equal [], Tracker.new.issue_statuses
Chris@1296 60 end
Chris@1296 61
Chris@1296 62 def test_core_fields_should_be_enabled_by_default
Chris@1296 63 tracker = Tracker.new
Chris@1296 64 assert_equal Tracker::CORE_FIELDS, tracker.core_fields
Chris@1296 65 assert_equal [], tracker.disabled_core_fields
Chris@1296 66 end
Chris@1296 67
Chris@1296 68 def test_core_fields
Chris@1296 69 tracker = Tracker.new
Chris@1296 70 tracker.core_fields = %w(assigned_to_id due_date)
Chris@1296 71
Chris@1296 72 assert_equal %w(assigned_to_id due_date), tracker.core_fields
Chris@1296 73 assert_equal Tracker::CORE_FIELDS - %w(assigned_to_id due_date), tracker.disabled_core_fields
Chris@1296 74 end
Chris@1296 75
Chris@1296 76 def test_core_fields_should_return_fields_enabled_for_any_tracker
Chris@1296 77 trackers = []
Chris@1296 78 trackers << Tracker.new(:core_fields => %w(assigned_to_id due_date))
Chris@1296 79 trackers << Tracker.new(:core_fields => %w(assigned_to_id done_ratio))
Chris@1296 80 trackers << Tracker.new(:core_fields => [])
Chris@1296 81
Chris@1296 82 assert_equal %w(assigned_to_id due_date done_ratio), Tracker.core_fields(trackers)
Chris@1296 83 assert_equal Tracker::CORE_FIELDS - %w(assigned_to_id due_date done_ratio), Tracker.disabled_core_fields(trackers)
Chris@1296 84 end
Chris@1296 85
Chris@1296 86 def test_core_fields_should_return_all_fields_for_an_empty_argument
Chris@1296 87 assert_equal Tracker::CORE_FIELDS, Tracker.core_fields([])
Chris@1296 88 assert_equal [], Tracker.disabled_core_fields([])
Chris@1296 89 end
Chris@1296 90
Chris@1296 91 def test_sort_should_sort_by_position
Chris@1296 92 a = Tracker.new(:name => 'Tracker A', :position => 2)
Chris@1296 93 b = Tracker.new(:name => 'Tracker B', :position => 1)
Chris@1296 94
Chris@1296 95 assert_equal [b, a], [a, b].sort
Chris@1296 96 end
Chris@1296 97
Chris@1296 98 def test_destroying_a_tracker_without_issues_should_not_raise_an_error
Chris@1296 99 tracker = Tracker.find(1)
Chris@1296 100 Issue.delete_all :tracker_id => tracker.id
Chris@1296 101
Chris@1296 102 assert_difference 'Tracker.count', -1 do
Chris@1296 103 assert_nothing_raised do
Chris@1296 104 tracker.destroy
Chris@1296 105 end
Chris@1296 106 end
Chris@1296 107 end
Chris@1296 108
Chris@1296 109 def test_destroying_a_tracker_with_issues_should_raise_an_error
Chris@1296 110 tracker = Tracker.find(1)
Chris@1296 111
Chris@1296 112 assert_no_difference 'Tracker.count' do
Chris@1296 113 assert_raise Exception do
Chris@1296 114 tracker.destroy
Chris@1296 115 end
Chris@1296 116 end
Chris@1296 117 end
Chris@1296 118 end