aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
Diffstat (limited to 'railties')
-rw-r--r--railties/CHANGELOG2
-rw-r--r--railties/lib/rails/plugin.rb1
-rw-r--r--railties/test/plugin_test.rb11
3 files changed, 14 insertions, 0 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG
index 2ee6fac28e..ddc1f7bc2a 100644
--- a/railties/CHANGELOG
+++ b/railties/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Ensure the plugin loader only loads plugins once. Closes #10102 [haruki_zaemon]
+
* Refactor Plugin Loader. Add plugin lib paths early, and add lots of tests. Closes #9795 [lazyatom]
* Added --skip-timestamps to generators that produce models #10036 [tpope]
diff --git a/railties/lib/rails/plugin.rb b/railties/lib/rails/plugin.rb
index 2feb90bf14..be392195d4 100644
--- a/railties/lib/rails/plugin.rb
+++ b/railties/lib/rails/plugin.rb
@@ -34,6 +34,7 @@ module Rails
# Evaluates a plugin's init.rb file
def load(initializer)
+ return if loaded?
report_nonexistant_or_empty_plugin! unless valid?
evaluate_init_rb(initializer)
@loaded = true
diff --git a/railties/test/plugin_test.rb b/railties/test/plugin_test.rb
index a791e42ae8..0f08c314db 100644
--- a/railties/test/plugin_test.rb
+++ b/railties/test/plugin_test.rb
@@ -119,6 +119,17 @@ uses_mocha "Plugin Tests" do
z = plugin_for("path/z")
assert_equal [a, b, z], [b, z, a].sort
end
+
+ def test_should_only_be_loaded_once
+ plugin = plugin_for(@valid_plugin_path)
+ assert !plugin.loaded?
+ plugin.expects(:evaluate_init_rb)
+ assert_nothing_raised do
+ plugin.send(:load, @initializer)
+ plugin.send(:load, @initializer)
+ end
+ assert plugin.loaded?
+ end
private