Skip to content

Commit

Permalink
Merge pull request rails#5692 from avakhov/force-ssl-if-test
Browse files Browse the repository at this point in the history
Tests :if option of force_ssl method
  • Loading branch information
josevalim committed Apr 1, 2012
2 parents 0244c0d + 7f6bb2d commit e357d5b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions actionpack/test/controller/force_ssl_test.rb
Expand Up @@ -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]

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit e357d5b

Please sign in to comment.