diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2010-07-14 13:38:36 +0200 |
---|---|---|
committer | Piotr Sarnacki <drogus@gmail.com> | 2010-09-03 22:59:04 +0200 |
commit | 15f95b98ac048407a1ce6873bb02fc5fbb6c991c (patch) | |
tree | ac71786040f34181e1297852ef63334ac4b336ee /railties/test | |
parent | efe9555cd77b409c6965bf803a47b1230ee7dec7 (diff) | |
download | rails-15f95b98ac048407a1ce6873bb02fc5fbb6c991c.tar.gz rails-15f95b98ac048407a1ce6873bb02fc5fbb6c991c.tar.bz2 rails-15f95b98ac048407a1ce6873bb02fc5fbb6c991c.zip |
Ensure that plugins are not loaded twice
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/railties/engine_test.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb index 39189edaa3..980265d969 100644 --- a/railties/test/railties/engine_test.rb +++ b/railties/test/railties/engine_test.rb @@ -1,8 +1,23 @@ require "isolation/abstract_unit" require "railties/shared_tests" +require 'stringio' module RailtiesTest class EngineTest < Test::Unit::TestCase + # TODO: it's copied from generators/test_case, maybe make a module with such helpers? + def capture(stream) + begin + stream = stream.to_s + eval "$#{stream} = StringIO.new" + yield + result = eval("$#{stream}").string + ensure + eval("$#{stream} = #{stream.upcase}") + end + + result + end + include ActiveSupport::Testing::Isolation include SharedTests @@ -126,5 +141,28 @@ module RailtiesTest assert Bukkits::Engine.config.yaffle_loaded end + + test "engine does not load plugins that already exists in application" do + @plugin.write "lib/bukkits.rb", <<-RUBY + class Bukkits + class Engine < ::Rails::Engine + end + end + RUBY + + @plugin.write "vendor/plugins/yaffle/init.rb", <<-RUBY + config.engine_yaffle_loaded = true + RUBY + + app_file "vendor/plugins/yaffle/init.rb", <<-RUBY + config.app_yaffle_loaded = true + RUBY + + warnings = capture(:stderr) { boot_rails } + + assert !warnings.empty? + assert !Bukkits::Engine.config.respond_to?(:engine_yaffle_loaded) + assert Rails.application.config.app_yaffle_loaded + end end end |