You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

document_category_test.rb 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # frozen_string_literal: true
  2. # Redmine - project management software
  3. # Copyright (C) 2006- 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_relative '../test_helper'
  19. class DocumentCategoryTest < ActiveSupport::TestCase
  20. fixtures :enumerations, :documents, :issues
  21. def setup
  22. User.current = nil
  23. end
  24. def test_should_be_an_enumeration
  25. assert DocumentCategory <= Enumeration
  26. end
  27. def test_objects_count
  28. assert_equal 2, DocumentCategory.find_by_name("Uncategorized").objects_count
  29. assert_equal 0, DocumentCategory.find_by_name("User documentation").objects_count
  30. end
  31. def test_option_name
  32. assert_equal :enumeration_doc_categories, DocumentCategory.new.option_name
  33. end
  34. def test_default
  35. assert_not DocumentCategory.where(:is_default => true).exists?
  36. e = Enumeration.find_by_name('Technical documentation')
  37. e.update(:is_default => true)
  38. assert_equal 3, DocumentCategory.default.id
  39. end
  40. def test_force_default
  41. assert_not DocumentCategory.where(:is_default => true).exists?
  42. assert_equal 1, DocumentCategory.default.id
  43. end
  44. end