diff options
author | José Valim <jose.valim@gmail.com> | 2011-05-06 08:35:57 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-05-06 08:35:57 -0700 |
commit | cae68d221cc81232e30049eafa4ff59b2c5f6010 (patch) | |
tree | ebff0feb10fe8a39a2a50b1be278e3e567576004 | |
parent | 0e5adbceb7d49f3448eec32a7068807f571bf76c (diff) | |
parent | a8cfceca55b36129f87a512c7852901e416a1ee9 (diff) | |
download | rails-cae68d221cc81232e30049eafa4ff59b2c5f6010.tar.gz rails-cae68d221cc81232e30049eafa4ff59b2c5f6010.tar.bz2 rails-cae68d221cc81232e30049eafa4ff59b2c5f6010.zip |
Merge pull request #414 from asanghi/lh5796
config.generators.orm = false when skipping active record. LightHouse #5796
-rw-r--r-- | railties/lib/rails/generators.rb | 4 | ||||
-rw-r--r-- | railties/lib/rails/generators/app_base.rb | 8 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/templates/config/application.rb | 10 | ||||
-rw-r--r-- | railties/test/generators/app_generator_test.rb | 10 |
4 files changed, 20 insertions, 12 deletions
diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb index 9be395e989..85c67af19a 100644 --- a/railties/lib/rails/generators.rb +++ b/railties/lib/rails/generators.rb @@ -52,13 +52,13 @@ module Rails :integration_tool => nil, :javascripts => true, :javascript_engine => nil, - :orm => nil, + :orm => false, :performance_tool => nil, :resource_controller => :controller, :scaffold_controller => :scaffold_controller, :stylesheets => true, :stylesheet_engine => nil, - :test_framework => nil, + :test_framework => false, :template_engine => :erb }, diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index 3d16304d86..e8709b2ddd 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -120,6 +120,14 @@ module Rails options[:skip_active_record] ? "" : "gem '#{gem_for_database}'\n" end + def include_all_railties? + !options[:skip_active_record] && !options[:skip_test_unit] + end + + def comment_if(value) + options[value] ? '#' : '' + end + def rails_gemfile_entry if options.dev? <<-GEMFILE.strip_heredoc diff --git a/railties/lib/rails/generators/rails/app/templates/config/application.rb b/railties/lib/rails/generators/rails/app/templates/config/application.rb index 3723addf2b..e1946807b0 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/application.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/application.rb @@ -1,14 +1,14 @@ require File.expand_path('../boot', __FILE__) -<% unless options[:skip_active_record] -%> +<% if include_all_railties? -%> require 'rails/all' <% else -%> # Pick the frameworks you want: -# require "active_record/railtie" +<%= comment_if :skip_active_record %> require "active_record/railtie" require "action_controller/railtie" require "action_mailer/railtie" require "active_resource/railtie" -require "rails/test_unit/railtie" +<%= comment_if :skip_test_unit %> require "rails/test_unit/railtie" <% end -%> # If you have a Gemfile, require the gems listed there, including any gems @@ -50,10 +50,6 @@ module <%= app_const_base %> # config.action_view.javascript_expansions[:defaults] = %w(prototype prototype_ujs) <% end -%> -<% if options[:skip_test_unit] -%> - config.generators.test_framework = false -<% end -%> - # Configure the default encoding used in templates for Ruby 1.9. config.encoding = "utf-8" diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index e271095636..8fb31a2429 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -227,9 +227,13 @@ class AppGeneratorTest < Rails::Generators::TestCase def test_test_unit_is_removed_from_frameworks_if_skip_test_unit_is_given run_generator [destination_root, "--skip-test-unit"] - assert_file "config/application.rb" do |file| - assert_match /config.generators.test_framework = false/, file - end + assert_file "config/application.rb", /#\s+require\s+["']rails\/test_unit\/railtie["']/ + end + + def test_no_active_record_or_test_unit_if_skips_given + run_generator [destination_root, "--skip-test-unit", "--skip-active-record"] + assert_file "config/application.rb", /#\s+require\s+["']rails\/test_unit\/railtie["']/ + assert_file "config/application.rb", /#\s+require\s+["']active_record\/railtie["']/ end def test_new_hash_style |