diff options
Diffstat (limited to 'actionpack/test/controller/force_ssl_test.rb')
-rw-r--r-- | actionpack/test/controller/force_ssl_test.rb | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/actionpack/test/controller/force_ssl_test.rb b/actionpack/test/controller/force_ssl_test.rb index 43b20fdead..7feeda25b3 100644 --- a/actionpack/test/controller/force_ssl_test.rb +++ b/actionpack/test/controller/force_ssl_test.rb @@ -26,6 +26,21 @@ class ForceSSLExceptAction < ForceSSLController force_ssl :except => :banana end +class ForceSSLFlash < ForceSSLController + force_ssl :except => [:banana, :set_flash, :use_flash] + + def set_flash + flash["that"] = "hello" + redirect_to '/force_ssl_flash/cheeseburger' + end + + def use_flash + @flash_copy = {}.update flash + @flashy = flash["that"] + render :inline => "hello" + end +end + class ForceSSLControllerLevelTest < ActionController::TestCase tests ForceSSLControllerLevel @@ -35,6 +50,12 @@ class ForceSSLControllerLevelTest < ActionController::TestCase assert_equal "https://test.host/force_ssl_controller_level/banana", redirect_to_url end + def test_banana_redirects_to_https_with_extra_params + get :banana, :token => "secret" + assert_response 301 + assert_equal "https://test.host/force_ssl_controller_level/banana?token=secret", redirect_to_url + end + def test_cheeseburger_redirects_to_https get :cheeseburger assert_response 301 @@ -50,7 +71,7 @@ class ForceSSLCustomDomainTest < ActionController::TestCase assert_response 301 assert_equal "https://secure.test.host/force_ssl_custom_domain/banana", redirect_to_url end - + def test_cheeseburger_redirects_to_https_with_custom_host get :cheeseburger assert_response 301 @@ -88,16 +109,20 @@ class ForceSSLExceptActionTest < ActionController::TestCase end end -class ForceSSLExcludeDevelopmentTest < ActionController::TestCase - tests ForceSSLControllerLevel +class ForceSSLFlashTest < ActionController::TestCase + tests ForceSSLFlash - def setup - Rails.env.stubs(:development?).returns(false) - end + def test_cheeseburger_redirects_to_https + get :set_flash + assert_response 302 + assert_equal "http://test.host/force_ssl_flash/cheeseburger", redirect_to_url - def test_development_environment_not_redirects_to_https - Rails.env.stubs(:development?).returns(true) - get :banana - assert_response 200 + get :cheeseburger + assert_response 301 + assert_equal "https://test.host/force_ssl_flash/cheeseburger", redirect_to_url + + get :use_flash + assert_equal "hello", assigns["flash_copy"]["that"] + assert_equal "hello", assigns["flashy"] end end |