From da1453e6bad5551dd85f9692b921e1ff770d0319 Mon Sep 17 00:00:00 2001 From: Taishi Kasuga Date: Thu, 24 Nov 2016 14:17:13 +0900 Subject: Remove aggressive unit test with mock. And add integration level test. --- actionpack/test/controller/force_ssl_test.rb | 24 ------------------------ railties/test/application/configuration_test.rb | 19 +++++++++++++++++++ railties/test/isolation/abstract_unit.rb | 1 - 3 files changed, 19 insertions(+), 25 deletions(-) diff --git a/actionpack/test/controller/force_ssl_test.rb b/actionpack/test/controller/force_ssl_test.rb index af3eedabe2..2b3859aa57 100644 --- a/actionpack/test/controller/force_ssl_test.rb +++ b/actionpack/test/controller/force_ssl_test.rb @@ -92,22 +92,6 @@ class RedirectToSSL < ForceSSLController end end -class RedirectToSSLIfSessionStoreDisabled < ForceSSLController - def banana - request.class_eval do - alias_method :flash_origin, :flash - undef_method :flash - end - - force_ssl_redirect || render(plain: "monkey") - ensure - request.class_eval do - alias_method :flash, :flash_origin - undef_method :flash_origin - end - end -end - class ForceSSLControllerLevelTest < ActionController::TestCase def test_banana_redirects_to_https get :banana @@ -337,14 +321,6 @@ class RedirectToSSLTest < ActionController::TestCase end end -class RedirectToSSLIfSessionStoreDisabledTest < ActionController::TestCase - def test_banana_redirects_to_https_if_not_https_and_session_store_disabled - get :banana - assert_response 301 - assert_equal "https://test.host/redirect_to_ssl_if_session_store_disabled/banana", redirect_to_url - end -end - class ForceSSLControllerLevelTest < ActionController::TestCase def test_no_redirect_websocket_ssl_request request.env["rack.url_scheme"] = "wss" 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 -- cgit v1.2.3