annotate .svn/pristine/fe/fec48c0854cc910d3994bec4099f1afa6bbe9778.svn-base @ 1524:82fac3dcf466 redmine-2.5-integration

Fix failure to interpret Javascript when autocompleting members for project
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Thu, 11 Sep 2014 10:24:38 +0100
parents dffacf8a6908
children
rev   line source
Chris@1517 1 # Redmine - project management software
Chris@1517 2 # Copyright (C) 2006-2014 Jean-Philippe Lang
Chris@1517 3 #
Chris@1517 4 # This program is free software; you can redistribute it and/or
Chris@1517 5 # modify it under the terms of the GNU General Public License
Chris@1517 6 # as published by the Free Software Foundation; either version 2
Chris@1517 7 # of the License, or (at your option) any later version.
Chris@1517 8 #
Chris@1517 9 # This program is distributed in the hope that it will be useful,
Chris@1517 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@1517 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@1517 12 # GNU General Public License for more details.
Chris@1517 13 #
Chris@1517 14 # You should have received a copy of the GNU General Public License
Chris@1517 15 # along with this program; if not, write to the Free Software
Chris@1517 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@1517 17
Chris@1517 18 require File.expand_path('../../test_helper', __FILE__)
Chris@1517 19
Chris@1517 20 class IssueStatusTest < ActiveSupport::TestCase
Chris@1517 21 fixtures :issue_statuses, :issues, :roles, :trackers
Chris@1517 22
Chris@1517 23 def test_create
Chris@1517 24 status = IssueStatus.new :name => "Assigned"
Chris@1517 25 assert !status.save
Chris@1517 26 # status name uniqueness
Chris@1517 27 assert_equal 1, status.errors.count
Chris@1517 28
Chris@1517 29 status.name = "Test Status"
Chris@1517 30 assert status.save
Chris@1517 31 assert !status.is_default
Chris@1517 32 end
Chris@1517 33
Chris@1517 34 def test_destroy
Chris@1517 35 status = IssueStatus.find(3)
Chris@1517 36 assert_difference 'IssueStatus.count', -1 do
Chris@1517 37 assert status.destroy
Chris@1517 38 end
Chris@1517 39 assert_nil WorkflowTransition.where(:old_status_id => status.id).first
Chris@1517 40 assert_nil WorkflowTransition.where(:new_status_id => status.id).first
Chris@1517 41 end
Chris@1517 42
Chris@1517 43 def test_destroy_status_in_use
Chris@1517 44 # Status assigned to an Issue
Chris@1517 45 status = Issue.find(1).status
Chris@1517 46 assert_raise(RuntimeError, "Can't delete status") { status.destroy }
Chris@1517 47 end
Chris@1517 48
Chris@1517 49 def test_default
Chris@1517 50 status = IssueStatus.default
Chris@1517 51 assert_kind_of IssueStatus, status
Chris@1517 52 end
Chris@1517 53
Chris@1517 54 def test_change_default
Chris@1517 55 status = IssueStatus.find(2)
Chris@1517 56 assert !status.is_default
Chris@1517 57 status.is_default = true
Chris@1517 58 assert status.save
Chris@1517 59 status.reload
Chris@1517 60
Chris@1517 61 assert_equal status, IssueStatus.default
Chris@1517 62 assert !IssueStatus.find(1).is_default
Chris@1517 63 end
Chris@1517 64
Chris@1517 65 def test_reorder_should_not_clear_default_status
Chris@1517 66 status = IssueStatus.default
Chris@1517 67 status.move_to_bottom
Chris@1517 68 status.reload
Chris@1517 69 assert status.is_default?
Chris@1517 70 end
Chris@1517 71
Chris@1517 72 def test_new_statuses_allowed_to
Chris@1517 73 WorkflowTransition.delete_all
Chris@1517 74
Chris@1517 75 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 2, :author => false, :assignee => false)
Chris@1517 76 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 3, :author => true, :assignee => false)
Chris@1517 77 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 4, :author => false, :assignee => true)
Chris@1517 78 WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 5, :author => true, :assignee => true)
Chris@1517 79 status = IssueStatus.find(1)
Chris@1517 80 role = Role.find(1)
Chris@1517 81 tracker = Tracker.find(1)
Chris@1517 82
Chris@1517 83 assert_equal [2], status.new_statuses_allowed_to([role], tracker, false, false).map(&:id)
Chris@1517 84 assert_equal [2], status.find_new_statuses_allowed_to([role], tracker, false, false).map(&:id)
Chris@1517 85
Chris@1517 86 assert_equal [2, 3, 5], status.new_statuses_allowed_to([role], tracker, true, false).map(&:id)
Chris@1517 87 assert_equal [2, 3, 5], status.find_new_statuses_allowed_to([role], tracker, true, false).map(&:id)
Chris@1517 88
Chris@1517 89 assert_equal [2, 4, 5], status.new_statuses_allowed_to([role], tracker, false, true).map(&:id)
Chris@1517 90 assert_equal [2, 4, 5], status.find_new_statuses_allowed_to([role], tracker, false, true).map(&:id)
Chris@1517 91
Chris@1517 92 assert_equal [2, 3, 4, 5], status.new_statuses_allowed_to([role], tracker, true, true).map(&:id)
Chris@1517 93 assert_equal [2, 3, 4, 5], status.find_new_statuses_allowed_to([role], tracker, true, true).map(&:id)
Chris@1517 94 end
Chris@1517 95
Chris@1517 96 def test_update_done_ratios_with_issue_done_ratio_set_to_issue_field_should_change_nothing
Chris@1517 97 IssueStatus.find(1).update_attribute(:default_done_ratio, 50)
Chris@1517 98
Chris@1517 99 with_settings :issue_done_ratio => 'issue_field' do
Chris@1517 100 IssueStatus.update_issue_done_ratios
Chris@1517 101 assert_equal 0, Issue.where(:done_ratio => 50).count
Chris@1517 102 end
Chris@1517 103 end
Chris@1517 104
Chris@1517 105 def test_update_done_ratios_with_issue_done_ratio_set_to_issue_status_should_update_issues
Chris@1517 106 IssueStatus.find(1).update_attribute(:default_done_ratio, 50)
Chris@1517 107 with_settings :issue_done_ratio => 'issue_status' do
Chris@1517 108 IssueStatus.update_issue_done_ratios
Chris@1517 109 issues = Issue.where(:status_id => 1)
Chris@1517 110 assert_equal [50], issues.map {|issue| issue.read_attribute(:done_ratio)}.uniq
Chris@1517 111 end
Chris@1517 112 end
Chris@1517 113
Chris@1517 114 def test_sorted_scope
Chris@1517 115 assert_equal IssueStatus.all.sort, IssueStatus.sorted.all
Chris@1517 116 end
Chris@1517 117
Chris@1517 118 def test_named_scope
Chris@1517 119 status = IssueStatus.named("resolved").first
Chris@1517 120 assert_not_nil status
Chris@1517 121 assert_equal "Resolved", status.name
Chris@1517 122 end
Chris@1517 123 end