Skip to content

Commit da1453e

Browse files
author
Taishi Kasuga
committed
Remove aggressive unit test with mock. And add integration level test.
1 parent 28f8914 commit da1453e

File tree

3 files changed

+19
-25
lines changed

3 files changed

+19
-25
lines changed

actionpack/test/controller/force_ssl_test.rb

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -92,22 +92,6 @@ def cheeseburger
9292
end
9393
end
9494

95-
class RedirectToSSLIfSessionStoreDisabled < ForceSSLController
96-
def banana
97-
request.class_eval do
98-
alias_method :flash_origin, :flash
99-
undef_method :flash
100-
end
101-
102-
force_ssl_redirect || render(plain: "monkey")
103-
ensure
104-
request.class_eval do
105-
alias_method :flash, :flash_origin
106-
undef_method :flash_origin
107-
end
108-
end
109-
end
110-
11195
class ForceSSLControllerLevelTest < ActionController::TestCase
11296
def test_banana_redirects_to_https
11397
get :banana
@@ -337,14 +321,6 @@ def test_cheeseburgers_does_not_redirect_if_already_https
337321
end
338322
end
339323

340-
class RedirectToSSLIfSessionStoreDisabledTest < ActionController::TestCase
341-
def test_banana_redirects_to_https_if_not_https_and_session_store_disabled
342-
get :banana
343-
assert_response 301
344-
assert_equal "https://test.host/redirect_to_ssl_if_session_store_disabled/banana", redirect_to_url
345-
end
346-
end
347-
348324
class ForceSSLControllerLevelTest < ActionController::TestCase
349325
def test_no_redirect_websocket_ssl_request
350326
request.env["rack.url_scheme"] = "wss"

railties/test/application/configuration_test.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff 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
15361555
end

railties/test/isolation/abstract_unit.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)