mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-19 15:01:14 +00:00
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
This commit is contained in:
parent
18a4f64547
commit
9cce7e85a2
@ -98,6 +98,10 @@ module Redmine
|
|||||||
# Set a default directory if it was not provided during registration
|
# Set a default directory if it was not provided during registration
|
||||||
p.directory(File.join(self.directory, id.to_s)) if p.directory.nil?
|
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
|
# Adds plugin locales if any
|
||||||
# YAML translation files should be found under <plugin>/config/locales/
|
# 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'))
|
Rails.application.config.i18n.load_path += Dir.glob(File.join(p.directory, 'config', 'locales', '*.yml'))
|
||||||
|
|||||||
@ -57,6 +57,14 @@ class Redmine::PluginTest < ActiveSupport::TestCase
|
|||||||
assert_equal '0.0.1', plugin.version
|
assert_equal '0.0.1', plugin.version
|
||||||
end
|
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
|
def test_installed
|
||||||
@klass.register(:foo_plugin) {}
|
@klass.register(:foo_plugin) {}
|
||||||
assert_equal true, @klass.installed?(:foo_plugin)
|
assert_equal true, @klass.installed?(:foo_plugin)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user