]> source.dussan.org Git - redmine.git/commitdiff
Add a warning if two plugins have the same settings partial name (#14008).
authorJean-Baptiste Barth <jeanbaptiste.barth@gmail.com>
Wed, 13 Aug 2014 04:56:44 +0000 (04:56 +0000)
committerJean-Baptiste Barth <jeanbaptiste.barth@gmail.com>
Wed, 13 Aug 2014 04:56:44 +0000 (04:56 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@13336 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/plugin.rb
test/unit/lib/redmine/plugin_test.rb

index e26ea91b90f64a9dda92f7e4f8eed035051e0683..9c67399d9ad4267977fbe69f62b02eeab143ee09 100644 (file)
@@ -50,6 +50,8 @@ module Redmine #:nodoc:
     self.public_directory = File.join(Rails.root, 'public', 'plugin_assets')
 
     @registered_plugins = {}
+    @used_partials = {}
+
     class << self
       attr_reader :registered_plugins
       private :new
@@ -93,6 +95,15 @@ module Redmine #:nodoc:
         ActiveSupport::Dependencies.autoload_paths += [dir]
       end
 
+      # Warn for potential settings[:partial] collisions
+      if p.configurable?
+        partial = p.settings[:partial]
+        if @used_partials[partial]
+          Rails.logger.warn "WARNING: settings partial '#{partial}' is declared in '#{p.id}' plugin but it is already used by plugin '#{@used_partials[partial]}'. Only one settings view will be used. You may want to contact those plugins authors to fix this."
+        end
+        @used_partials[partial] = p.id
+      end
+
       registered_plugins[id] = p
     end
 
index 1853b678e87e3e0991381551a2e1c55fe42fefa1..dfce0406069f0b649ab6dc4deefb6ff6f2fd01af 100644 (file)
@@ -173,4 +173,10 @@ class Redmine::PluginTest < ActiveSupport::TestCase
       end
     end
   end
+
+  def test_settings_warns_about_possible_partial_collision
+    @klass.register(:foo) { settings :partial => 'foo/settings' }
+    Rails.logger.expects(:warn)
+    @klass.register(:bar) { settings :partial => 'foo/settings' }
+  end
 end