Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Tests :if option of force_ssl method #5692

Merged
merged 1 commit into from

2 participants

@avakhov

I suggest to add simple test for check :if switch of method force_ssl. This behaviour is described in the documentation action_controller/metal/force_ssl.rb#L24, let test it.

@josevalim josevalim merged commit e357d5b into rails:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 1, 2012
  1. @avakhov
This page is out of date. Refresh to see the latest.
Showing with 23 additions and 0 deletions.
  1. +23 −0 actionpack/test/controller/force_ssl_test.rb
View
23 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 @@ def test_cheeseburger_redirects_to_https
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
Something went wrong with that request. Please try again.