diff options
author | José Valim <jose.valim@gmail.com> | 2012-04-01 04:43:22 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2012-04-01 04:43:22 -0700 |
commit | e357d5b99343f6470dd3fe8bfc410a4227f3ba93 (patch) | |
tree | d88386a768fc1bab566ab490d4a3f7435991dc86 | |
parent | 0244c0d8f339385a9b420a0565b17d327bf25b13 (diff) | |
parent | 7f6bb2d86dd2fcf6d97ad8eb0e3e3032e2e602d6 (diff) | |
download | rails-e357d5b99343f6470dd3fe8bfc410a4227f3ba93.tar.gz rails-e357d5b99343f6470dd3fe8bfc410a4227f3ba93.tar.bz2 rails-e357d5b99343f6470dd3fe8bfc410a4227f3ba93.zip |
Merge pull request #5692 from avakhov/force-ssl-if-test
Tests :if option of force_ssl method
-rw-r--r-- | actionpack/test/controller/force_ssl_test.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/actionpack/test/controller/force_ssl_test.rb b/actionpack/test/controller/force_ssl_test.rb index 7feeda25b3..5b423c8151 100644 --- a/actionpack/test/controller/force_ssl_test.rb +++ b/actionpack/test/controller/force_ssl_test.rb @@ -26,6 +26,14 @@ class ForceSSLExceptAction < ForceSSLController force_ssl :except => :banana end +class ForceSSLIfCondition < ForceSSLController + force_ssl :if => :use_force_ssl? + + def use_force_ssl? + action_name == 'cheeseburger' + end +end + class ForceSSLFlash < ForceSSLController force_ssl :except => [:banana, :set_flash, :use_flash] @@ -109,6 +117,21 @@ class ForceSSLExceptActionTest < ActionController::TestCase end end +class ForceSSLIfConditionTest < ActionController::TestCase + tests ForceSSLIfCondition + + def test_banana_not_redirects_to_https + get :banana + assert_response 200 + end + + def test_cheeseburger_redirects_to_https + get :cheeseburger + assert_response 301 + assert_equal "https://test.host/force_ssl_if_condition/cheeseburger", redirect_to_url + end +end + class ForceSSLFlashTest < ActionController::TestCase tests ForceSSLFlash |