提交 cfbe5958 编写于 作者: P Piotr Sarnacki

Use application's generators defaults as engine defaults to not force users to manually set it

上级 9e86767b
...@@ -14,7 +14,7 @@ class Railtie < Rails::Railtie ...@@ -14,7 +14,7 @@ class Railtie < Rails::Railtie
config.active_record = ActiveSupport::OrderedOptions.new config.active_record = ActiveSupport::OrderedOptions.new
config.app_generators.orm :active_record, :migration => true, config.app_generators.orm :active_record, :migration => true,
:timestamps => true :timestamps => true
config.app_middleware.insert_after "::ActionDispatch::Callbacks", config.app_middleware.insert_after "::ActionDispatch::Callbacks",
"ActiveRecord::QueryCache" "ActiveRecord::QueryCache"
......
...@@ -10,6 +10,7 @@ class Configuration < ::Rails::Railtie::Configuration ...@@ -10,6 +10,7 @@ class Configuration < ::Rails::Railtie::Configuration
def initialize(root=nil) def initialize(root=nil)
super() super()
@root = root @root = root
@generators = app_generators
end end
# Returns the middleware stack for the engine. # Returns the middleware stack for the engine.
......
...@@ -685,5 +685,22 @@ class Engine < ::Rails::Engine ...@@ -685,5 +685,22 @@ class Engine < ::Rails::Engine
assert_equal :haml , generators[:template_engine] assert_equal :haml , generators[:template_engine]
assert_equal :rspec , generators[:test_framework] assert_equal :rspec , generators[:test_framework]
end end
test "engine should get default generators with ability to overwrite them" do
@plugin.write "lib/bukkits.rb", <<-RUBY
module Bukkits
class Engine < ::Rails::Engine
config.generators.test_framework :rspec
end
end
RUBY
boot_rails
require "#{rails_root}/config/environment"
generators = Bukkits::Engine.config.generators.options[:rails]
assert_equal :active_record, generators[:orm]
assert_equal :rspec , generators[:test_framework]
end
end end
end end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册