diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2016-03-21 14:01:06 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2016-03-21 14:01:06 -0300 |
commit | d5977c67bdd6a459e21328cb8c0cf2cf47ccc185 (patch) | |
tree | c986d3456b411e75e96a047529778908ff3123b7 /railties/test | |
parent | dda31d59a03adb7e5aa372e72bb66a3886632f2f (diff) | |
parent | 6c6a22176f01b563a7b731fee9f37c837ba83320 (diff) | |
download | rails-d5977c67bdd6a459e21328cb8c0cf2cf47ccc185.tar.gz rails-d5977c67bdd6a459e21328cb8c0cf2cf47ccc185.tar.bz2 rails-d5977c67bdd6a459e21328cb8c0cf2cf47ccc185.zip |
Merge pull request #24229 from maclover7/fix-24222
Fix request.reset_session for API controllers
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/application/middleware/flash_test.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/railties/test/application/middleware/flash_test.rb b/railties/test/application/middleware/flash_test.rb new file mode 100644 index 0000000000..f5d459c695 --- /dev/null +++ b/railties/test/application/middleware/flash_test.rb @@ -0,0 +1,46 @@ +require 'isolation/abstract_unit' +require 'rack/test' + +module ApplicationTests + class FlashTest < ActiveSupport::TestCase + include ActiveSupport::Testing::Isolation + include Rack::Test::Methods + + def setup + build_app + boot_rails + end + + def teardown + teardown_app + 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 + + app 'development' + + 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 |