Browse Source

Raise an exception if the plugin directory name differs from the plugin id (#31110).

Patch by Mizuki ISHIKAWA.


git-svn-id: http://svn.redmine.org/redmine/trunk@18064 e93f8b46-1217-0410-a6f0-8f06a7374b81
tags/4.1.0
Go MAEDA 5 years ago
parent
commit
9cce7e85a2
2 changed files with 12 additions and 0 deletions
  1. 4
    0
      lib/redmine/plugin.rb
  2. 8
    0
      test/unit/lib/redmine/plugin_test.rb

+ 4
- 0
lib/redmine/plugin.rb View 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'))

+ 8
- 0
test/unit/lib/redmine/plugin_test.rb View 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)

Loading…
Cancel
Save