diff --git a/railties/lib/rails/tasks/framework.rake b/railties/lib/rails/tasks/framework.rake index ae928364073293834af4978062bab59ef7607661..4c98b8647389bc1a5874f93818fbf6a4abb40697 100644 --- a/railties/lib/rails/tasks/framework.rake +++ b/railties/lib/rails/tasks/framework.rake @@ -47,8 +47,9 @@ namespace :app do @app_generator ||= begin require 'rails/generators' require 'rails/generators/rails/app/app_generator' - gen = Rails::Generators::AppGenerator.new ["rails"], { with_dispatchers: true, api: !!Rails.application.config.api_only }, - destination_root: Rails.root + gen = Rails::Generators::AppGenerator.new ["rails"], + { api: !!Rails.application.config.api_only }, + destination_root: Rails.root File.exist?(Rails.root.join("config", "application.rb")) ? gen.send(:app_const) : gen.send(:valid_const?) gen diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 63655044da9013acfa36237c76f9aaa81b07e517..ac49f0606ea86cea2a2e7ec05aafdeb1d2606e1a 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -125,7 +125,7 @@ def test_application_name_is_detected_if_it_exists_and_app_folder_renamed # make sure we are in correct dir FileUtils.cd(app_moved_root) - generator = Rails::Generators::AppGenerator.new ["rails"], { with_dispatchers: true }, + generator = Rails::Generators::AppGenerator.new ["rails"], [], destination_root: app_moved_root, shell: @shell generator.send(:app_const) quietly { generator.send(:update_config_files) } @@ -140,7 +140,7 @@ def test_rails_update_generates_correct_session_key run_generator [app_root] stub_rails_application(app_root) do - generator = Rails::Generators::AppGenerator.new ["rails"], { with_dispatchers: true }, destination_root: app_root, shell: @shell + generator = Rails::Generators::AppGenerator.new ["rails"], [], destination_root: app_root, shell: @shell generator.send(:app_const) quietly { generator.send(:update_config_files) } assert_file "myapp/config/initializers/session_store.rb", /_myapp_session/ @@ -164,7 +164,7 @@ def test_rails_update_keep_the_cookie_serializer_if_it_is_already_configured run_generator [app_root] stub_rails_application(app_root) do - generator = Rails::Generators::AppGenerator.new ["rails"], { with_dispatchers: true }, destination_root: app_root, shell: @shell + generator = Rails::Generators::AppGenerator.new ["rails"], [], destination_root: app_root, shell: @shell generator.send(:app_const) quietly { generator.send(:update_config_files) } assert_file("#{app_root}/config/initializers/cookies_serializer.rb", /Rails\.application\.config\.action_dispatch\.cookies_serializer = :json/) @@ -178,7 +178,7 @@ def test_rails_update_does_not_create_callback_terminator_initializer FileUtils.rm("#{app_root}/config/initializers/callback_terminator.rb") stub_rails_application(app_root) do - generator = Rails::Generators::AppGenerator.new ["rails"], { with_dispatchers: true }, destination_root: app_root, shell: @shell + generator = Rails::Generators::AppGenerator.new ["rails"], [], destination_root: app_root, shell: @shell generator.send(:app_const) quietly { generator.send(:update_config_files) } assert_no_file "#{app_root}/config/initializers/callback_terminator.rb" @@ -192,7 +192,7 @@ def test_rails_update_does_not_remove_callback_terminator_initializer_if_already FileUtils.touch("#{app_root}/config/initializers/callback_terminator.rb") stub_rails_application(app_root) do - generator = Rails::Generators::AppGenerator.new ["rails"], { with_dispatchers: true }, destination_root: app_root, shell: @shell + generator = Rails::Generators::AppGenerator.new ["rails"], [], destination_root: app_root, shell: @shell generator.send(:app_const) quietly { generator.send(:update_config_files) } assert_file "#{app_root}/config/initializers/callback_terminator.rb" @@ -206,7 +206,7 @@ def test_rails_update_set_the_cookie_serializer_to_marchal_if_it_is_not_already_ FileUtils.rm("#{app_root}/config/initializers/cookies_serializer.rb") stub_rails_application(app_root) do - generator = Rails::Generators::AppGenerator.new ["rails"], { with_dispatchers: true }, destination_root: app_root, shell: @shell + generator = Rails::Generators::AppGenerator.new ["rails"], [], destination_root: app_root, shell: @shell generator.send(:app_const) quietly { generator.send(:update_config_files) } assert_file("#{app_root}/config/initializers/cookies_serializer.rb", /Rails\.application\.config\.action_dispatch\.cookies_serializer = :marshal/) @@ -220,7 +220,7 @@ def test_rails_update_does_not_create_active_record_belongs_to_required_by_defau FileUtils.rm("#{app_root}/config/initializers/active_record_belongs_to_required_by_default.rb") stub_rails_application(app_root) do - generator = Rails::Generators::AppGenerator.new ["rails"], { with_dispatchers: true }, destination_root: app_root, shell: @shell + generator = Rails::Generators::AppGenerator.new ["rails"], [], destination_root: app_root, shell: @shell generator.send(:app_const) quietly { generator.send(:update_config_files) } assert_no_file "#{app_root}/config/initializers/active_record_belongs_to_required_by_default.rb" @@ -234,7 +234,7 @@ def test_rails_update_does_not_remove_active_record_belongs_to_required_by_defau FileUtils.touch("#{app_root}/config/initializers/active_record_belongs_to_required_by_default.rb") stub_rails_application(app_root) do - generator = Rails::Generators::AppGenerator.new ["rails"], { with_dispatchers: true }, destination_root: app_root, shell: @shell + generator = Rails::Generators::AppGenerator.new ["rails"], [], destination_root: app_root, shell: @shell generator.send(:app_const) quietly { generator.send(:update_config_files) } assert_file "#{app_root}/config/initializers/active_record_belongs_to_required_by_default.rb" @@ -248,7 +248,7 @@ def test_rails_update_does_not_create_ssl_options_by_default FileUtils.rm("#{app_root}/config/initializers/ssl_options.rb") stub_rails_application(app_root) do - generator = Rails::Generators::AppGenerator.new ["rails"], { with_dispatchers: true }, destination_root: app_root, shell: @shell + generator = Rails::Generators::AppGenerator.new ["rails"], [], destination_root: app_root, shell: @shell generator.send(:app_const) quietly { generator.send(:update_config_files) } assert_no_file "#{app_root}/config/initializers/ssl_options.rb" @@ -262,7 +262,7 @@ def test_rails_update_does_not_remove_ssl_options_if_already_present FileUtils.touch("#{app_root}/config/initializers/ssl_options.rb") stub_rails_application(app_root) do - generator = Rails::Generators::AppGenerator.new ["rails"], { with_dispatchers: true }, destination_root: app_root, shell: @shell + generator = Rails::Generators::AppGenerator.new ["rails"], [], destination_root: app_root, shell: @shell generator.send(:app_const) quietly { generator.send(:update_config_files) } assert_file "#{app_root}/config/initializers/ssl_options.rb" @@ -274,7 +274,7 @@ def test_rails_update_does_not_create_rack_cors run_generator [app_root] stub_rails_application(app_root) do - generator = Rails::Generators::AppGenerator.new ["rails"], { with_dispatchers: true }, destination_root: app_root, shell: @shell + generator = Rails::Generators::AppGenerator.new ["rails"], [], destination_root: app_root, shell: @shell generator.send(:app_const) quietly { generator.send(:update_config_files) } assert_no_file "#{app_root}/config/initializers/cors.rb" @@ -288,7 +288,7 @@ def test_rails_update_does_not_remove_rack_cors_if_already_present FileUtils.touch("#{app_root}/config/initializers/cors.rb") stub_rails_application(app_root) do - generator = Rails::Generators::AppGenerator.new ["rails"], { with_dispatchers: true }, destination_root: app_root, shell: @shell + generator = Rails::Generators::AppGenerator.new ["rails"], [], destination_root: app_root, shell: @shell generator.send(:app_const) quietly { generator.send(:update_config_files) } assert_file "#{app_root}/config/initializers/cors.rb"