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.

plugin_loader_test.rb 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # frozen_string_literal: true
  2. # Redmine - project management software
  3. # Copyright (C) 2006-2022 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 Redmine::PluginLoaderTest < ActiveSupport::TestCase
  20. def setup
  21. clear_public
  22. @klass = Redmine::PluginLoader
  23. @klass.directory = Rails.root.join('test/fixtures/plugins')
  24. @klass.public_directory = Rails.root.join('tmp/public/plugin_assets')
  25. @klass.load
  26. end
  27. def teardown
  28. clear_public
  29. end
  30. def test_create_assets_reloader
  31. plugin_assets = @klass.create_assets_reloader
  32. plugin_assets.execute.inspect
  33. assert File.exist?("#{@klass.public_directory}/foo_plugin")
  34. assert File.exist?("#{@klass.public_directory}/foo_plugin/stylesheets/foo.css")
  35. end
  36. def test_mirror_assets
  37. Redmine::PluginLoader.mirror_assets
  38. assert File.exist?("#{@klass.public_directory}/foo_plugin")
  39. assert File.exist?("#{@klass.public_directory}/foo_plugin/stylesheets/foo.css")
  40. end
  41. def test_mirror_assets_with_plugin_name
  42. Redmine::PluginLoader.mirror_assets('foo_plugin')
  43. assert File.exist?("#{@klass.public_directory}/foo_plugin")
  44. assert File.exist?("#{@klass.public_directory}/foo_plugin/stylesheets/foo.css")
  45. end
  46. def clear_public
  47. FileUtils.rm_rf 'tmp/public'
  48. end
  49. end