diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2016-11-25 10:55:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-25 10:55:03 +0100 |
commit | 6c873236d4384e6a89981a524867ddee4828097a (patch) | |
tree | f2696018f1e3e8527550ee346f276592d1625690 | |
parent | bce2e64e1022dc48577a7b6090fa79adcb559d11 (diff) | |
parent | da1453e6bad5551dd85f9692b921e1ff770d0319 (diff) | |
download | rails-6c873236d4384e6a89981a524867ddee4828097a.tar.gz rails-6c873236d4384e6a89981a524867ddee4828097a.tar.bz2 rails-6c873236d4384e6a89981a524867ddee4828097a.zip |
Merge pull request #27140 from supercaracal/fix-force-ssl-if-session-store-disabled
Fix a force ssl redirection bug that occur when session store disabled.
-rw-r--r-- | actionpack/lib/action_controller/metal/force_ssl.rb | 2 | ||||
-rw-r--r-- | railties/test/application/configuration_test.rb | 19 | ||||
-rw-r--r-- | railties/test/isolation/abstract_unit.rb | 1 |
3 files changed, 20 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/metal/force_ssl.rb b/actionpack/lib/action_controller/metal/force_ssl.rb index b8976497a4..9d43e752ac 100644 --- a/actionpack/lib/action_controller/metal/force_ssl.rb +++ b/actionpack/lib/action_controller/metal/force_ssl.rb @@ -89,7 +89,7 @@ module ActionController end secure_url = ActionDispatch::Http::URL.url_for(options.slice(*URL_OPTIONS)) - flash.keep if respond_to?(:flash) + flash.keep if respond_to?(:flash) && request.respond_to?(:flash) redirect_to secure_url, options.slice(*REDIRECT_OPTIONS) end end diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 7e3bd26212..c409f1ea79 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -1532,5 +1532,24 @@ module ApplicationTests assert_equal :default, Rails.configuration.debug_exception_response_format end + + test "controller force_ssl declaration can be used even if session_store is disabled" do + make_basic_app do |application| + application.config.session_store :disabled + end + + class ::OmgController < ActionController::Base + force_ssl + + def index + render plain: "Yay! You're on Rails!" + end + end + + get "/" + + assert_equal 301, last_response.status + assert_equal "https://example.org/", last_response.location + end end end diff --git a/railties/test/isolation/abstract_unit.rb b/railties/test/isolation/abstract_unit.rb index aa0a06faf1..1902eac862 100644 --- a/railties/test/isolation/abstract_unit.rb +++ b/railties/test/isolation/abstract_unit.rb @@ -162,7 +162,6 @@ module TestHelpers require "rails" require "action_controller/railtie" require "action_view/railtie" - require "action_dispatch/middleware/flash" @app = Class.new(Rails::Application) @app.config.eager_load = false |