Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

issue_category_test.rb 2.0KB

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