diff options
Diffstat (limited to 'railties/test/application')
-rw-r--r-- | railties/test/application/configuration_test.rb | 4 | ||||
-rw-r--r-- | railties/test/application/initializers/i18n_test.rb | 8 | ||||
-rw-r--r-- | railties/test/application/middleware/session_test.rb | 28 | ||||
-rw-r--r-- | railties/test/application/rake/dev_test.rb | 2 | ||||
-rw-r--r-- | railties/test/application/rake_test.rb | 14 |
5 files changed, 45 insertions, 11 deletions
diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index d03dd1afcc..decc4d138d 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -1337,7 +1337,7 @@ module ApplicationTests assert_equal 'custom key', Rails.application.config.my_custom_config['key'] end - test "config_for use the Pathname object if it is provided" do + test "config_for uses the Pathname object if it is provided" do app_file 'config/custom.yml', <<-RUBY development: key: 'custom key' @@ -1464,7 +1464,7 @@ module ApplicationTests assert_equal :api, Rails.configuration.debug_exception_response_format end - test "debug_exception_response_format can be override" do + test "debug_exception_response_format can be overriden" do add_to_config <<-RUBY config.api_only = true RUBY diff --git a/railties/test/application/initializers/i18n_test.rb b/railties/test/application/initializers/i18n_test.rb index ab7f29b0f2..0f9bb41053 100644 --- a/railties/test/application/initializers/i18n_test.rb +++ b/railties/test/application/initializers/i18n_test.rb @@ -245,7 +245,7 @@ fr: assert_fallbacks de: [:de, :'en-US', :en] end - test "[shortcut] config.i18n.fallbacks = [{ :ca => :'es-ES' }] initializes fallbacks with a mapping de-AT => de-DE" do + test "[shortcut] config.i18n.fallbacks = [{ :ca => :'es-ES' }] initializes fallbacks with a mapping ca => es-ES" do I18n::Railtie.config.i18n.fallbacks.map = { :ca => :'es-ES' } load_app assert_fallbacks ca: [:ca, :"es-ES", :es, :en] @@ -257,6 +257,12 @@ fr: assert_fallbacks ca: [:ca, :"es-ES", :es, :'en-US', :en] end + test "[shortcut] config.i18n.fallbacks = { ca: :en } initializes fallbacks with a mapping ca => :en" do + I18n::Railtie.config.i18n.fallbacks = { ca: :en } + load_app + assert_fallbacks ca: [:ca, :en] + end + test "disable config.i18n.enforce_available_locales" do add_to_config <<-RUBY config.i18n.enforce_available_locales = false diff --git a/railties/test/application/middleware/session_test.rb b/railties/test/application/middleware/session_test.rb index f847e80471..85e7761727 100644 --- a/railties/test/application/middleware/session_test.rb +++ b/railties/test/application/middleware/session_test.rb @@ -345,5 +345,33 @@ module ApplicationTests get '/foo/read_raw_cookie' assert_equal 2, verifier.verify(last_response.body)['foo'] end + + test 'calling reset_session on request does not trigger an error for API apps' do + add_to_config 'config.api_only = true' + + controller :test, <<-RUBY + class TestController < ApplicationController + def dump_flash + request.reset_session + render plain: 'It worked!' + end + end + RUBY + + app_file 'config/routes.rb', <<-RUBY + Rails.application.routes.draw do + get '/dump_flash' => "test#dump_flash" + end + RUBY + + require "#{app_path}/config/environment" + + get '/dump_flash' + + assert_equal 200, last_response.status + assert_equal 'It worked!', last_response.body + + refute Rails.application.middleware.include?(ActionDispatch::Flash) + end end end diff --git a/railties/test/application/rake/dev_test.rb b/railties/test/application/rake/dev_test.rb index 43d7a5e156..59b46c6e79 100644 --- a/railties/test/application/rake/dev_test.rb +++ b/railties/test/application/rake/dev_test.rb @@ -15,7 +15,7 @@ module ApplicationTests test 'dev:cache creates file and outputs message' do Dir.chdir(app_path) do - output = `rake dev:cache` + output = `rails dev:cache` assert File.exist?('tmp/caching-dev.txt') assert_match(/Development mode is now being cached/, output) end diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb index dc3c4755c7..1a786a3fd3 100644 --- a/railties/test/application/rake_test.rb +++ b/railties/test/application/rake_test.rb @@ -24,7 +24,7 @@ module ApplicationTests assert $task_loaded end - def test_the_test_rake_task_is_protected_when_previous_migration_was_production + test "task is protected when previous migration was production" do Dir.chdir(app_path) do output = `bin/rails generate model product name:string; env RAILS_ENV=production bin/rails db:create db:migrate; @@ -122,7 +122,7 @@ module ApplicationTests Dir.chdir(app_path){ `bin/rails stats` } end - def test_rake_routes_calls_the_route_inspector + def test_rails_routes_calls_the_route_inspector app_file "config/routes.rb", <<-RUBY Rails.application.routes.draw do get '/cart', to: 'cart#show' @@ -133,7 +133,7 @@ module ApplicationTests assert_equal "Prefix Verb URI Pattern Controller#Action\n cart GET /cart(.:format) cart#show\n", output end - def test_rake_routes_with_controller_environment + def test_rails_routes_with_controller_environment app_file "config/routes.rb", <<-RUBY Rails.application.routes.draw do get '/cart', to: 'cart#show' @@ -151,7 +151,7 @@ module ApplicationTests assert_equal "Prefix Verb URI Pattern Controller#Action\n cart GET /cart(.:format) cart#show\n", output end - def test_rake_routes_with_namespaced_controller_environment + def test_rails_routes_with_namespaced_controller_environment app_file "config/routes.rb", <<-RUBY Rails.application.routes.draw do namespace :admin do @@ -175,7 +175,7 @@ module ApplicationTests assert_equal expected_output, output end - def test_rake_routes_with_global_search_key + def test_rails_routes_with_global_search_key app_file "config/routes.rb", <<-RUBY Rails.application.routes.draw do get '/cart', to: 'cart#show' @@ -195,7 +195,7 @@ module ApplicationTests "basketballs GET /basketballs(.:format) basketball#index\n", output end - def test_rake_routes_with_controller_search_key + def test_rails_routes_with_controller_search_key app_file "config/routes.rb", <<-RUBY Rails.application.routes.draw do get '/cart', to: 'cart#show' @@ -213,7 +213,7 @@ module ApplicationTests assert_equal "Prefix Verb URI Pattern Controller#Action\n cart GET /cart(.:format) cart#show\n", output end - def test_rake_routes_displays_message_when_no_routes_are_defined + def test_rails_routes_displays_message_when_no_routes_are_defined app_file "config/routes.rb", <<-RUBY Rails.application.routes.draw do end |