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.

default_data_test.rb 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 DefaultDataTest < ActiveSupport::TestCase
  20. include Redmine::I18n
  21. fixtures :roles
  22. def setup
  23. User.current = nil
  24. end
  25. def test_no_data
  26. assert !Redmine::DefaultData::Loader::no_data?
  27. clear_data
  28. assert Redmine::DefaultData::Loader::no_data?
  29. end
  30. def test_load
  31. clear_data
  32. assert Redmine::DefaultData::Loader::load('en')
  33. assert DocumentCategory.exists?
  34. assert IssuePriority.exists?
  35. assert TimeEntryActivity.exists?
  36. assert WorkflowTransition.exists?
  37. assert Query.exists?
  38. end
  39. def test_load_for_all_language
  40. valid_languages.each do |lang|
  41. clear_data
  42. begin
  43. assert Redmine::DefaultData::Loader::load(lang, :workflow => false)
  44. assert DocumentCategory.exists?
  45. assert IssuePriority.exists?
  46. assert TimeEntryActivity.exists?
  47. assert Query.exists?
  48. rescue ActiveRecord::RecordInvalid => e
  49. assert false, ":#{lang} default data is invalid (#{e.message})."
  50. end
  51. end
  52. end
  53. def clear_data
  54. Role.where("builtin = 0").delete_all
  55. Tracker.delete_all
  56. IssueStatus.delete_all
  57. Enumeration.delete_all
  58. WorkflowRule.delete_all
  59. Query.delete_all
  60. end
  61. end