Skip to content

Commit

Permalink
Only pick the frameworks in the application.rb if the test_unit is not
Browse files Browse the repository at this point in the history
present.

rails/all already catches load errors.

Closes rails#5652
  • Loading branch information
rafaelfranca committed Apr 2, 2012
1 parent 39fd844 commit ba41eec
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
@@ -1,6 +1,6 @@
require File.expand_path('../boot', __FILE__) require File.expand_path('../boot', __FILE__)


<% if include_all_railties? -%> <% unless options.skip_test_unit? -%>
require 'rails/all' require 'rails/all'
<% else -%> <% else -%>
# Pick the frameworks you want: # Pick the frameworks you want:
Expand Down
18 changes: 15 additions & 3 deletions railties/test/generators/app_generator_test.rb
Expand Up @@ -219,7 +219,7 @@ def test_generator_if_skip_active_record_is_given
assert_match(/gem ["']actionmailer["']/, gemfile_content) assert_match(/gem ["']actionmailer["']/, gemfile_content)
assert_match(/gem ["']sprockets-rails["'], '~> 1\.0'/, gemfile_content) assert_match(/gem ["']sprockets-rails["'], '~> 1\.0'/, gemfile_content)
end end
assert_file "config/application.rb", /#\s+require\s+["']active_record\/railtie["']/ assert_file "config/application.rb", /\s+require\s+["']rails\/all["']/
assert_file "config/application.rb", /#\s+config\.active_record\.whitelist_attributes = true/ assert_file "config/application.rb", /#\s+config\.active_record\.whitelist_attributes = true/
assert_file "config/application.rb", /#\s+config\.active_record\.dependent_restrict_raises = false/ assert_file "config/application.rb", /#\s+config\.active_record\.dependent_restrict_raises = false/
assert_file "test/test_helper.rb" do |helper_content| assert_file "test/test_helper.rb" do |helper_content|
Expand All @@ -237,7 +237,7 @@ def test_generator_if_skip_action_mailer_is_given
assert_match(/# gem ["']actionmailer["']/, gemfile_content) assert_match(/# gem ["']actionmailer["']/, gemfile_content)
assert_match(/gem ["']sprockets-rails["'], '~> 1\.0'/, gemfile_content) assert_match(/gem ["']sprockets-rails["'], '~> 1\.0'/, gemfile_content)
end end
assert_file "config/application.rb", /#\s+require\s+["']action_mailer\/railtie["']/ assert_file "config/application.rb", /\s+require\s+["']rails\/all["']/
assert_file "config/environments/development.rb" do |content| assert_file "config/environments/development.rb" do |content|
assert_no_match(/config\.action_mailer\.raise_delivery_errors = false/, content) assert_no_match(/config\.action_mailer\.raise_delivery_errors = false/, content)
end end
Expand All @@ -259,7 +259,7 @@ def test_generator_if_skip_sprockets_is_given
assert_match(/# gem ["']sprockets-rails["'], '~> 1\.0'/, gemfile_content) assert_match(/# gem ["']sprockets-rails["'], '~> 1\.0'/, gemfile_content)
end end
assert_file "config/application.rb" do |content| assert_file "config/application.rb" do |content|
assert_match(/#\s+require\s+["']sprockets\/rails\/railtie["']/, content) assert_match(/\s+require\s+["']rails\/all["']/, content)
assert_no_match(/config\.assets\.enabled = true/, content) assert_no_match(/config\.assets\.enabled = true/, content)
end end
assert_file "Gemfile" do |content| assert_file "Gemfile" do |content|
Expand Down Expand Up @@ -372,6 +372,18 @@ def test_no_active_record_or_test_unit_if_skips_given
assert_file "config/application.rb", /#\s+require\s+["']active_record\/railtie["']/ assert_file "config/application.rb", /#\s+require\s+["']active_record\/railtie["']/
end end


def test_no_action_mailer_or_test_unit_if_skips_given
run_generator [destination_root, "--skip-test-unit", "--skip-action-mailer"]
assert_file "config/application.rb", /#\s+require\s+["']rails\/test_unit\/railtie["']/
assert_file "config/application.rb", /#\s+require\s+["']action_mailer\/railtie["']/
end

def test_no_sprockets_or_test_unit_if_skips_given
run_generator [destination_root, "--skip-test-unit", "--skip-sprockets"]
assert_file "config/application.rb", /#\s+require\s+["']rails\/test_unit\/railtie["']/
assert_file "config/application.rb", /#\s+require\s+["']sprockets\/rails\/railtie["']/
end

def test_new_hash_style def test_new_hash_style
run_generator [destination_root] run_generator [destination_root]
assert_file "config/initializers/session_store.rb" do |file| assert_file "config/initializers/session_store.rb" do |file|
Expand Down

0 comments on commit ba41eec

Please sign in to comment.