annotate test/unit/issue_category_test.rb @ 1628:9c5f8e24dadc live tip

Quieten this cron script
author Chris Cannam
date Tue, 25 Aug 2020 11:38:49 +0100
parents dffacf8a6908
children
rev   line source
Chris@909 1 # Redmine - project management software
Chris@1494 2 # Copyright (C) 2006-2014 Jean-Philippe Lang
Chris@0 3 #
Chris@0 4 # This program is free software; you can redistribute it and/or
Chris@0 5 # modify it under the terms of the GNU General Public License
Chris@0 6 # as published by the Free Software Foundation; either version 2
Chris@0 7 # of the License, or (at your option) any later version.
Chris@909 8 #
Chris@0 9 # This program is distributed in the hope that it will be useful,
Chris@0 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@0 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@0 12 # GNU General Public License for more details.
Chris@909 13 #
Chris@0 14 # You should have received a copy of the GNU General Public License
Chris@0 15 # along with this program; if not, write to the Free Software
Chris@0 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@0 17
Chris@119 18 require File.expand_path('../../test_helper', __FILE__)
Chris@0 19
Chris@0 20 class IssueCategoryTest < ActiveSupport::TestCase
Chris@1115 21 fixtures :issue_categories, :issues, :users, :groups_users
Chris@0 22
Chris@0 23 def setup
Chris@0 24 @category = IssueCategory.find(1)
Chris@0 25 end
Chris@909 26
Chris@909 27 def test_create
Chris@909 28 assert IssueCategory.new(:project_id => 2, :name => 'New category').save
Chris@1517 29 category = IssueCategory.order('id DESC').first
Chris@909 30 assert_equal 'New category', category.name
Chris@909 31 end
Chris@909 32
Chris@909 33 def test_create_with_group_assignment
Chris@909 34 assert IssueCategory.new(:project_id => 2, :name => 'Group assignment', :assigned_to_id => 11).save
Chris@1517 35 category = IssueCategory.order('id DESC').first
Chris@909 36 assert_kind_of Group, category.assigned_to
Chris@909 37 assert_equal Group.find(11), category.assigned_to
Chris@909 38 end
Chris@909 39
Chris@0 40 def test_destroy
Chris@0 41 issue = @category.issues.first
Chris@0 42 @category.destroy
Chris@0 43 # Make sure the category was nullified on the issue
Chris@0 44 assert_nil issue.reload.category
Chris@0 45 end
Chris@909 46
Chris@0 47 def test_destroy_with_reassign
Chris@0 48 issue = @category.issues.first
Chris@0 49 reassign_to = IssueCategory.find(2)
Chris@0 50 @category.destroy(reassign_to)
Chris@0 51 # Make sure the issue was reassigned
Chris@0 52 assert_equal reassign_to, issue.reload.category
Chris@0 53 end
Chris@0 54 end