diff options
author | Yoshiyuki Hirano <yhirano@me.com> | 2017-08-13 10:37:14 +0900 |
---|---|---|
committer | Yoshiyuki Hirano <yhirano@me.com> | 2017-08-13 15:19:03 +0900 |
commit | 6df78be9bb7035ec73837e9be41781e563da2ab4 (patch) | |
tree | 8e8937360f8fe92363084f7945b6dc91d93600fd /railties/test | |
parent | e3962308e7947f3d99c70c192e2d1356d3420e1e (diff) | |
download | rails-6df78be9bb7035ec73837e9be41781e563da2ab4.tar.gz rails-6df78be9bb7035ec73837e9be41781e563da2ab4.tar.bz2 rails-6df78be9bb7035ec73837e9be41781e563da2ab4.zip |
Refactor `--api` option of the app generator
It can't use JavaScript in api mode.
Action cable should be disabled by default.
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/generators/api_app_generator_test.rb | 55 | ||||
-rw-r--r-- | railties/test/generators/app_generator_test.rb | 8 |
2 files changed, 41 insertions, 22 deletions
diff --git a/railties/test/generators/api_app_generator_test.rb b/railties/test/generators/api_app_generator_test.rb index a19e0f0dd8..58bc59a19f 100644 --- a/railties/test/generators/api_app_generator_test.rb +++ b/railties/test/generators/api_app_generator_test.rb @@ -33,26 +33,26 @@ class ApiAppGeneratorTest < Rails::Generators::TestCase def test_api_modified_files run_generator + assert_file ".gitignore" do |content| + assert_no_match(/\/public\/asserts/, content) + end + assert_file "Gemfile" do |content| assert_no_match(/gem 'coffee-rails'/, content) assert_no_match(/gem 'sass-rails'/, content) assert_no_match(/gem 'web-console'/, content) + assert_no_match(/gem 'capybara'/, content) + assert_no_match(/gem 'selenium-webdriver'/, content) assert_match(/# gem 'jbuilder'/, content) + assert_match(/# gem 'rack-cors'/, content) end - assert_file "config/application.rb" do |content| - assert_match(/config.api_only = true/, content) - end - - assert_file "config/initializers/cors.rb" - - assert_file "config/initializers/wrap_parameters.rb" - + assert_file "config/application.rb", /config\.api_only = true/ assert_file "app/controllers/application_controller.rb", /ActionController::API/ end def test_generator_if_skip_action_cable_is_given - run_generator [destination_root, "--skip-action-cable"] + run_generator [destination_root, "--api", "--skip-action-cable"] assert_file "config/application.rb", /#\s+require\s+["']action_cable\/engine["']/ assert_no_file "config/cable.yml" assert_no_file "app/channels" @@ -85,20 +85,49 @@ class ApiAppGeneratorTest < Rails::Generators::TestCase private def default_files - files = %W( - .gitignore + %w(.gitignore + .ruby-version + README.md Gemfile Rakefile config.ru + app/channels app/controllers app/mailers app/models + app/views/layouts app/views/layouts/mailer.html.erb app/views/layouts/mailer.text.erb + bin/bundle + bin/rails + bin/rake + bin/setup + bin/update + config/application.rb + config/boot.rb + config/cable.yml + config/environment.rb config/environments + config/environments/development.rb + config/environments/production.rb + config/environments/test.rb config/initializers + config/initializers/application_controller_renderer.rb + config/initializers/backtrace_silencers.rb + config/initializers/cors.rb + config/initializers/filter_parameter_logging.rb + config/initializers/inflections.rb + config/initializers/mime_types.rb + config/initializers/wrap_parameters.rb config/locales + config/locales/en.yml + config/puma.rb + config/routes.rb + config/secrets.yml + config/spring.rb + config/storage.yml db + db/seeds.rb lib lib/tasks log @@ -109,8 +138,6 @@ class ApiAppGeneratorTest < Rails::Generators::TestCase tmp vendor ) - files.concat %w(bin/bundle bin/rails bin/rake) - files end def skipped_files @@ -128,7 +155,7 @@ class ApiAppGeneratorTest < Rails::Generators::TestCase public/500.html public/apple-touch-icon-precomposed.png public/apple-touch-icon.png - public/favicon.icon + public/favicon.ico package.json ) end diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index ff73014046..704fe09d0a 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -535,14 +535,6 @@ class AppGeneratorTest < Rails::Generators::TestCase end end - def test_generator_if_api_is_given - run_generator [destination_root, "--api"] - assert_file "Gemfile" do |content| - assert_no_match(/capybara/, content) - assert_no_match(/selenium-webdriver/, content) - end - end - def test_inclusion_of_javascript_runtime run_generator if defined?(JRUBY_VERSION) |