Ensure the plugin loader only loads plugins once. Closes #10102 [haruki_zaemon]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8116 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Rick Olson 2007-11-08 15:41:46 +00:00
parent f1b1af88b5
commit fcfcc707d4
3 changed files with 14 additions and 0 deletions

View File

@ -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]

View File

@ -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

View File

@ -120,6 +120,17 @@ uses_mocha "Plugin Tests" do
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
def plugin_for(path)