Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #414 from asanghi/lh5796

config.generators.orm = false when skipping active record. LightHouse #5796
  • Loading branch information...
commit cae68d221cc81232e30049eafa4ff59b2c5f6010 2 parents 0e5adbc + a8cfcec
@josevalim josevalim authored
View
4 railties/lib/rails/generators.rb
@@ -52,13 +52,13 @@ module Generators
: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
},
View
8 railties/lib/rails/generators/app_base.rb
@@ -120,6 +120,14 @@ def database_gemfile_entry
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
View
10 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 @@ class Application < Rails::Application
# 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"
View
10 railties/test/generators/app_generator_test.rb
@@ -227,9 +227,13 @@ def test_file_is_added_for_backwards_compatibility
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
Please sign in to comment.
Something went wrong with that request. Please try again.