diff options
author | José Valim <jose.valim@gmail.com> | 2010-01-24 12:49:12 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-01-24 12:49:12 +0100 |
commit | dd05b6c543f48050f494214da7803da6f5655292 (patch) | |
tree | 189258330438a7604e0e7efee059be1ad6a37dbc /railties | |
parent | e548f96b1d5cb6529dd6fbc6544f03a3a840b48c (diff) | |
download | rails-dd05b6c543f48050f494214da7803da6f5655292.tar.gz rails-dd05b6c543f48050f494214da7803da6f5655292.tar.bz2 rails-dd05b6c543f48050f494214da7803da6f5655292.zip |
Add tests for plugin sanity check.
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/engine/configurable.rb | 3 | ||||
-rw-r--r-- | railties/lib/rails/plugin.rb | 3 | ||||
-rw-r--r-- | railties/test/plugins/vendored_test.rb | 24 |
3 files changed, 27 insertions, 3 deletions
diff --git a/railties/lib/rails/engine/configurable.rb b/railties/lib/rails/engine/configurable.rb index d4b7ecc532..9a370f0abb 100644 --- a/railties/lib/rails/engine/configurable.rb +++ b/railties/lib/rails/engine/configurable.rb @@ -3,10 +3,11 @@ module Rails module Configurable def self.included(base) base.extend ClassMethods - base.delegate :middleware, :root, :paths, :to => :config end module ClassMethods + delegate :middleware, :root, :paths, :to => :config + def config @config ||= Engine::Configuration.new(find_root_with_flag("lib")) end diff --git a/railties/lib/rails/plugin.rb b/railties/lib/rails/plugin.rb index b47679d140..4c73809177 100644 --- a/railties/lib/rails/plugin.rb +++ b/railties/lib/rails/plugin.rb @@ -49,10 +49,9 @@ module Rails eval(File.read(file), binding, file) if file && File.file?(file) end - # TODO Write tests for this sanity check initializer :sanity_check_railties_collision do if Engine.subclasses.map { |k| k.root.to_s }.include?(root.to_s) - raise "The plugin #{name.inspect} is a Railtie or an Engine and cannot be installed as Plugin" + raise "\"#{name}\" is a Railtie/Engine and cannot be installed as plugin" end end end diff --git a/railties/test/plugins/vendored_test.rb b/railties/test/plugins/vendored_test.rb index 1fc8766def..86f3ecd1f7 100644 --- a/railties/test/plugins/vendored_test.rb +++ b/railties/test/plugins/vendored_test.rb @@ -247,6 +247,30 @@ YAML assert_equal 200, last_response.status assert_equal "Rendered from namespace", last_response.body end + + test "plugin cannot declare an engine for it" do + @plugin.write "lib/bukkits.rb", <<-RUBY + class Bukkits + class Engine < Rails::Engine + end + end + RUBY + + @plugin.write "init.rb", <<-RUBY + require "bukkits" + RUBY + + rescued = false + + begin + boot_rails + rescue Exception => e + rescued = true + assert_equal '"bukkits" is a Railtie/Engine and cannot be installed as plugin', e.message + end + + assert rescued, "Expected boot rails to fail" + end end class VendoredOrderingTest < Test::Unit::TestCase |