Allow plugins to define their base directory (#13927).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11766 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
501007f01d
commit
e771d68214
|
@ -64,15 +64,18 @@ module Redmine #:nodoc:
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def_field :name, :description, :url, :author, :author_url, :version, :settings
|
def_field :name, :description, :url, :author, :author_url, :version, :settings, :directory
|
||||||
attr_reader :id
|
attr_reader :id
|
||||||
|
|
||||||
# Plugin constructor
|
# Plugin constructor
|
||||||
def self.register(id, &block)
|
def self.register(id, &block)
|
||||||
p = new(id)
|
p = new(id)
|
||||||
p.instance_eval(&block)
|
p.instance_eval(&block)
|
||||||
|
|
||||||
# Set a default name if it was not provided during registration
|
# Set a default name if it was not provided during registration
|
||||||
p.name(id.to_s.humanize) if p.name.nil?
|
p.name(id.to_s.humanize) if p.name.nil?
|
||||||
|
# Set a default directory if it was not provided during registration
|
||||||
|
p.directory(File.join(self.directory, id.to_s)) if p.directory.nil?
|
||||||
|
|
||||||
# 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/
|
||||||
|
@ -137,10 +140,6 @@ module Redmine #:nodoc:
|
||||||
@id = id.to_sym
|
@id = id.to_sym
|
||||||
end
|
end
|
||||||
|
|
||||||
def directory
|
|
||||||
File.join(self.class.directory, id.to_s)
|
|
||||||
end
|
|
||||||
|
|
||||||
def public_directory
|
def public_directory
|
||||||
File.join(self.class.public_directory, id.to_s)
|
File.join(self.class.public_directory, id.to_s)
|
||||||
end
|
end
|
||||||
|
|
|
@ -83,6 +83,18 @@ class Redmine::PluginTest < ActiveSupport::TestCase
|
||||||
assert_nil Redmine::MenuManager.items(:project_menu).detect {|i| i.name == :foo_menu_item}
|
assert_nil Redmine::MenuManager.items(:project_menu).detect {|i| i.name == :foo_menu_item}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_directory_with_override
|
||||||
|
@klass.register(:foo) do
|
||||||
|
directory '/path/to/foo'
|
||||||
|
end
|
||||||
|
assert_equal '/path/to/foo', @klass.find('foo').directory
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_directory_without_override
|
||||||
|
@klass.register(:foo) {}
|
||||||
|
assert_equal File.join(@klass.directory, 'foo'), @klass.find('foo').directory
|
||||||
|
end
|
||||||
|
|
||||||
def test_requires_redmine
|
def test_requires_redmine
|
||||||
plugin = Redmine::Plugin.register(:foo) {}
|
plugin = Redmine::Plugin.register(:foo) {}
|
||||||
Redmine::VERSION.stubs(:to_a).returns([2, 1, 3, "stable", 10817])
|
Redmine::VERSION.stubs(:to_a).returns([2, 1, 3, "stable", 10817])
|
||||||
|
|
Loading…
Reference in New Issue