mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Make Rails::Configuration::Generators accessor consistent
Rails::Configuration::Generators provides method_missing based accessor. The following code sets `orm` value: Rails.application.config.generators.orm :data_mapper The following code does NOT return `orm` value: Rails.application.config.generators.orm # => {} It's better that the reader returns the value set by writter in terms of consistency: Rails.application.config.generators.orm # => :data_mapper
This commit is contained in:
parent
3a6770fb51
commit
4334299b65
2 changed files with 20 additions and 14 deletions
|
@ -110,7 +110,13 @@ module Rails
|
|||
def method_missing(method, *args)
|
||||
method = method.to_s.sub(/=$/, "").to_sym
|
||||
|
||||
return @options[method] if args.empty?
|
||||
if args.empty?
|
||||
if method == :rails
|
||||
return @options[method]
|
||||
else
|
||||
return @options[:rails][method]
|
||||
end
|
||||
end
|
||||
|
||||
if method == :rails || args.first.is_a?(Hash)
|
||||
namespace, configuration = method, args.shift
|
||||
|
|
|
@ -1029,15 +1029,15 @@ en:
|
|||
|
||||
boot_rails
|
||||
|
||||
app_generators = Rails.application.config.generators.options[:rails]
|
||||
assert_equal :mongoid, app_generators[:orm]
|
||||
assert_equal :liquid, app_generators[:template_engine]
|
||||
assert_equal :test_unit, app_generators[:test_framework]
|
||||
app_generators = Rails.application.config.generators
|
||||
assert_equal :mongoid, app_generators.orm
|
||||
assert_equal :liquid, app_generators.template_engine
|
||||
assert_equal :test_unit, app_generators.test_framework
|
||||
|
||||
generators = Bukkits::Engine.config.generators.options[:rails]
|
||||
assert_equal :data_mapper, generators[:orm]
|
||||
assert_equal :haml, generators[:template_engine]
|
||||
assert_equal :rspec, generators[:test_framework]
|
||||
generators = Bukkits::Engine.config.generators
|
||||
assert_equal :data_mapper, generators.orm
|
||||
assert_equal :haml, generators.template_engine
|
||||
assert_equal :rspec, generators.test_framework
|
||||
end
|
||||
|
||||
test "engine should get default generators with ability to overwrite them" do
|
||||
|
@ -1051,12 +1051,12 @@ en:
|
|||
|
||||
boot_rails
|
||||
|
||||
generators = Bukkits::Engine.config.generators.options[:rails]
|
||||
assert_equal :active_record, generators[:orm]
|
||||
assert_equal :rspec, generators[:test_framework]
|
||||
generators = Bukkits::Engine.config.generators
|
||||
assert_equal :active_record, generators.orm
|
||||
assert_equal :rspec, generators.test_framework
|
||||
|
||||
app_generators = Rails.application.config.generators.options[:rails]
|
||||
assert_equal :test_unit, app_generators[:test_framework]
|
||||
app_generators = Rails.application.config.generators
|
||||
assert_equal :test_unit, app_generators.test_framework
|
||||
end
|
||||
|
||||
test "do not create table_name_prefix method if it already exists" do
|
||||
|
|
Loading…
Reference in a new issue