]> source.dussan.org Git - redmine.git/commitdiff
Raise an exception if the plugin directory name differs from the plugin id (#31110).
authorGo MAEDA <maeda@farend.jp>
Fri, 19 Apr 2019 15:30:41 +0000 (15:30 +0000)
committerGo MAEDA <maeda@farend.jp>
Fri, 19 Apr 2019 15:30:41 +0000 (15:30 +0000)
Patch by Mizuki ISHIKAWA.

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

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

index a8e523bfe919f7576dfd1deed81616f06b374831..b5fa3d209dbe043bb096e891ddfa42154b15af74 100644 (file)
@@ -98,6 +98,10 @@ module Redmine
       # Set a default directory if it was not provided during registration
       p.directory(File.join(self.directory, id.to_s)) if p.directory.nil?
 
+      unless File.directory?(p.directory)
+        raise PluginNotFound, "Plugin not found. The directory for plugin #{p.id} should be #{p.directory}."
+      end
+
       # Adds plugin locales if any
       # YAML translation files should be found under <plugin>/config/locales/
       Rails.application.config.i18n.load_path += Dir.glob(File.join(p.directory, 'config', 'locales', '*.yml'))
index 29facdd3aab2fe25f352c7338260e360aad39b49..e56de307b7681972095a74bd41dc3bb242275799 100644 (file)
@@ -57,6 +57,14 @@ class Redmine::PluginTest < ActiveSupport::TestCase
     assert_equal '0.0.1', plugin.version
   end
 
+  def test_register_should_raise_error_if_plugin_directory_does_not_exist
+    e = assert_raises Redmine::PluginNotFound do
+      @klass.register(:bar_plugin) {}
+    end
+
+    assert_equal "Plugin not found. The directory for plugin bar_plugin should be #{Rails.root.join('test/fixtures/plugins/bar_plugin')}.", e.message
+  end
+
   def test_installed
     @klass.register(:foo_plugin) {}
     assert_equal true, @klass.installed?(:foo_plugin)