提交 2068b8cb 编写于 作者: P Piotr Sarnacki

Added tests for railtie_name and aliased it in engine as engine_name

上级 bfccbc6d
......@@ -166,6 +166,7 @@ class Engine < Railtie
class << self
attr_accessor :called_from
alias :engine_name :railtie_name
def inherited(base)
unless base.abstract_railtie?
......@@ -201,6 +202,7 @@ def endpoint(endpoint = nil)
end
delegate :middleware, :root, :paths, :to => :config
delegate :engine_name, :to => "self.class"
def load_tasks
super
......
......@@ -19,6 +19,22 @@ def app
assert !Rails::Railtie.respond_to?(:config)
end
test "Railtie provides railtie_name" do
begin
class ::Foo < Rails::Railtie ; end
assert_equal "foo", ::Foo.railtie_name
ensure
Object.send(:remove_const, :"Foo")
end
end
test "railtie_name can be set manualy" do
class Foo < Rails::Railtie
railtie_name "bar"
end
assert_equal "bar", Foo.railtie_name
end
test "cannot inherit from a railtie" do
class Foo < Rails::Railtie ; end
assert_raise RuntimeError do
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册