提交 dd05b6c5 编写于 作者: J José Valim

Add tests for plugin sanity check.

上级 e548f96b
......@@ -3,10 +3,11 @@ class Engine
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
......
......@@ -49,10 +49,9 @@ def config
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
......
......@@ -247,6 +247,30 @@ def index
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册