File tree Expand file tree Collapse file tree 3 files changed +20
-2
lines changed
actionpack/lib/action_controller/metal Expand file tree Collapse file tree 3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ def force_ssl_redirect(host_or_options = nil)
8989 end
9090
9191 secure_url = ActionDispatch ::Http ::URL . url_for ( options . slice ( *URL_OPTIONS ) )
92- flash . keep if respond_to? ( :flash )
92+ flash . keep if respond_to? ( :flash ) && request . respond_to? ( :flash )
9393 redirect_to secure_url , options . slice ( *REDIRECT_OPTIONS )
9494 end
9595 end
Original file line number Diff line number Diff line change @@ -1532,5 +1532,24 @@ def index
15321532
15331533 assert_equal :default , Rails . configuration . debug_exception_response_format
15341534 end
1535+
1536+ test "controller force_ssl declaration can be used even if session_store is disabled" do
1537+ make_basic_app do |application |
1538+ application . config . session_store :disabled
1539+ end
1540+
1541+ class ::OmgController < ActionController ::Base
1542+ force_ssl
1543+
1544+ def index
1545+ render plain : "Yay! You're on Rails!"
1546+ end
1547+ end
1548+
1549+ get "/"
1550+
1551+ assert_equal 301 , last_response . status
1552+ assert_equal "https://example.org/" , last_response . location
1553+ end
15351554 end
15361555end
Original file line number Diff line number Diff line change @@ -162,7 +162,6 @@ def make_basic_app
162162 require "rails"
163163 require "action_controller/railtie"
164164 require "action_view/railtie"
165- require "action_dispatch/middleware/flash"
166165
167166 @app = Class . new ( Rails ::Application )
168167 @app . config . eager_load = false
You can’t perform that action at this time.
0 commit comments