]> source.dussan.org Git - redmine.git/commitdiff
Fix Redmine::Plugin.assets_directory is not working after r21283 (#36835).
authorMarius Balteanu <marius.balteanu@zitec.com>
Thu, 24 Mar 2022 16:47:54 +0000 (16:47 +0000)
committerMarius Balteanu <marius.balteanu@zitec.com>
Thu, 24 Mar 2022 16:47:54 +0000 (16:47 +0000)
Patch by Go MAEDA.

git-svn-id: https://svn.redmine.org/redmine/trunk@21498 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/plugin.rb
test/unit/lib/redmine/plugin_test.rb

index cdc6defb3e66eac37554906d512eec370a4e50af..fb42a8fa98c6f54c66cf94d2daa4a95a3b6c7df9 100644 (file)
@@ -104,7 +104,7 @@ module Redmine
         raise PluginNotFound, "Plugin not found. The directory for plugin #{p.id} should be #{p.directory}."
       end
 
-      p.path = PluginLoader.directories{ |d| d.dir == p.directory }
+      p.path = PluginLoader.directories.find {|d| d.to_s == p.directory}
 
       # Adds plugin locales if any
       # YAML translation files should be found under <plugin>/config/locales/
@@ -183,7 +183,7 @@ module Redmine
 
     # Returns the absolute path to the plugin assets directory
     def assets_directory
-      path.assedts_dir
+      path.assets_dir
     end
 
     def <=>(plugin)
index 75c8ece9b3cf3c9d9503eab5cc6556b1df4a8f66..54394ab5794472738c55f4d4d5a504d938addb63 100644 (file)
@@ -27,6 +27,10 @@ class Redmine::PluginTest < ActiveSupport::TestCase
     @klass.directory = Rails.root.join('test/fixtures/plugins')
     # In case some real plugins are installed
     @klass.clear
+
+    # Change plugin loader's directory for testing
+    Redmine::PluginLoader.directory = @klass.directory
+    Redmine::PluginLoader.setup
   end
 
   def teardown
@@ -55,6 +59,7 @@ class Redmine::PluginTest < ActiveSupport::TestCase
     assert_equal 'http://example.net/jsmith', plugin.author_url
     assert_equal 'This is a test plugin', plugin.description
     assert_equal '0.0.1', plugin.version
+    assert_equal File.join(@klass.directory, 'foo_plugin', 'assets'), plugin.assets_directory
   end
 
   def test_register_should_raise_error_if_plugin_directory_does_not_exist