From b608e0e20767ebfb1b2423af1336ab1b1535f749 Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Tue, 9 Sep 2014 17:14:55 +0200 Subject: [PATCH] prevent duplicate loading of patch We have to patch the originating module and not the application helper for that --- lib/open_project/documents/engine.rb | 7 ++++++- ...pplication_helper_patch.rb => text_formatting_patch.rb} | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) rename lib/open_project/documents/patches/{application_helper_patch.rb => text_formatting_patch.rb} (91%) diff --git a/lib/open_project/documents/engine.rb b/lib/open_project/documents/engine.rb index d5d117a74d..df7f2a1229 100644 --- a/lib/open_project/documents/engine.rb +++ b/lib/open_project/documents/engine.rb @@ -60,7 +60,7 @@ module OpenProject::Documents Redmine::Search.register :documents end - patches [:ApplicationHelper, :CustomFieldsHelper, :Project] + patches [:CustomFieldsHelper, :Project] assets %w(documents.css) @@ -75,6 +75,11 @@ module OpenProject::Documents config.to_prepare do require_dependency 'document_category' require_dependency 'document_category_custom_field' + + # Have to apply this one by hand and not via op_engine patches method + # becauses the op_engine method does not allow for patching something + # in the lib/open_project directory. Bummer. + require_dependency 'open_project/documents/patches/text_formatting_patch' end end end diff --git a/lib/open_project/documents/patches/application_helper_patch.rb b/lib/open_project/documents/patches/text_formatting_patch.rb similarity index 91% rename from lib/open_project/documents/patches/application_helper_patch.rb rename to lib/open_project/documents/patches/text_formatting_patch.rb index 41c5ec450d..85ff2f6b12 100644 --- a/lib/open_project/documents/patches/application_helper_patch.rb +++ b/lib/open_project/documents/patches/text_formatting_patch.rb @@ -30,7 +30,7 @@ #++ module OpenProject::Documents::Patches - module ApplicationHelperPatch + module TextFormattingPatch def self.included(base) base.class_eval do @@ -69,6 +69,6 @@ module OpenProject::Documents::Patches end end -unless ApplicationHelper.included_modules.include?(OpenProject::Documents::Patches::ApplicationHelperPatch) - ApplicationHelper.send(:include, OpenProject::Documents::Patches::ApplicationHelperPatch) +unless OpenProject::TextFormatting.included_modules.include?(OpenProject::Documents::Patches::TextFormattingPatch) + OpenProject::TextFormatting.send(:include, OpenProject::Documents::Patches::TextFormattingPatch) end