Patch by Jens Krämer (@jkraemer). git-svn-id: https://svn.redmine.org/redmine/trunk@22747 e93f8b46-1217-0410-a6f0-8f06a7374b81pull/149/head
Redmine::WikiFormatting.register(name, *args) | Redmine::WikiFormatting.register(name, *args) | ||||
end | end | ||||
# Register plugin models that use acts_as_attachable. | |||||
# | |||||
# Example: | |||||
# attachment_object_type SomeAttachableModel | |||||
# | |||||
# This is necessary for the core attachments controller routes and attachments/_form to work. | |||||
def attachment_object_type(*args) | |||||
args.each do |klass| | |||||
Redmine::Acts::Attachable::ObjectTypeConstraint.register_object_type(klass.name.underscore.pluralize) | |||||
end | |||||
end | |||||
# Returns +true+ if the plugin can be configured. | # Returns +true+ if the plugin can be configured. | ||||
def configurable? | def configurable? | ||||
settings && settings.is_a?(Hash) && settings[:partial].present? | settings && settings.is_a?(Hash) && settings[:partial].present? |
assert_equal File.join(@klass.directory, 'foo_plugin', 'assets'), plugin.assets_directory | assert_equal File.join(@klass.directory, 'foo_plugin', 'assets'), plugin.assets_directory | ||||
end | end | ||||
::FooModel = Class.new(ActiveRecord::Base) | |||||
def test_register_attachment_object_type | |||||
Redmine::Acts::Attachable::ObjectTypeConstraint.expects(:register_object_type).with("foo_models") | |||||
@klass.register :foo_plugin do | |||||
attachment_object_type FooModel | |||||
end | |||||
end | |||||
def test_register_should_raise_error_if_plugin_directory_does_not_exist | def test_register_should_raise_error_if_plugin_directory_does_not_exist | ||||
e = assert_raises Redmine::PluginNotFound do | e = assert_raises Redmine::PluginNotFound do | ||||
@klass.register(:bar_plugin) {} | @klass.register(:bar_plugin) {} |