aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/generators/app_generator_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'railties/test/generators/app_generator_test.rb')
-rw-r--r--railties/test/generators/app_generator_test.rb36
1 files changed, 34 insertions, 2 deletions
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb
index cf6f9b90c9..363155bc55 100644
--- a/railties/test/generators/app_generator_test.rb
+++ b/railties/test/generators/app_generator_test.rb
@@ -213,7 +213,7 @@ class AppGeneratorTest < Rails::Generators::TestCase
def test_generator_if_skip_sprockets_is_given
run_generator [destination_root, "--skip-sprockets"]
assert_file "config/application.rb" do |content|
- assert_match(/#\s+require\s+["']sprockets\/railtie["']/, content)
+ assert_match(/#\s+require\s+["']sprockets\/rails\/railtie["']/, content)
assert_no_match(/config\.assets\.enabled = true/, content)
end
assert_file "Gemfile" do |content|
@@ -361,6 +361,39 @@ class AppGeneratorTest < Rails::Generators::TestCase
assert_file "config/application.rb", /config\.active_record\.dependent_restrict_raises = false/
end
+ def test_http_generates_config_middleware_and_generator_http_setup
+ run_generator [destination_root, "--http"]
+ assert_file "config/application.rb", /config\.middleware\.http_only!/,
+ /config\.generators\.http_only!/
+ end
+
+ def test_http_generates_application_controller_with_action_controller_http
+ run_generator [destination_root, "--http"]
+ assert_file "app/controllers/application_controller.rb",
+ /class ApplicationController < ActionController::HTTP/
+ end
+
+ def test_http_generates_application_controller_with_protect_from_forgery_commented_out_setup
+ run_generator [destination_root, "--http"]
+ assert_file "app/controllers/application_controller.rb", /^ # protect_from_forgery/
+ end
+
+ def test_http_does_not_generate_app_views_dir
+ run_generator [destination_root, "--http"]
+ assert_no_directory "app/views"
+ end
+
+ def test_http_skip_sprockets_entries_in_gemfile_and_application
+ run_generator [destination_root, "--http"]
+ assert_file "Gemfile" do |content|
+ assert_no_match(/group :assets/, content)
+ end
+ assert_file "config/application.rb" do |content|
+ assert_match(/^# require "sprockets/, content)
+ assert_no_match(/config\.assets/, content)
+ end
+ end
+
def test_pretend_option
output = run_generator [File.join(destination_root, "myapp"), "--pretend"]
assert_no_match(/run bundle install/, output)
@@ -371,7 +404,6 @@ protected
def action(*args, &block)
silence(:stdout) { generator.send(*args, &block) }
end
-
end
class CustomAppGeneratorTest < Rails::Generators::TestCase