Permalink
Browse files

Add tests for redirect_to handling

  - test that we redirect if ssl request but request.host does not match redirect_to
  - test that we do not redirect if ssl request and request.host matches redirect_to
  • Loading branch information...
1 parent d0b882a commit 5628267aad6f3330ee9aafeaa3a88ecbc6587bc1 Tobias Matthies committed Mar 10, 2012
Showing with 8 additions and 2 deletions.
  1. +8 −2 test/rack-ssl-enforcer_test.rb
@@ -109,9 +109,15 @@ class TestRackSslEnforcer < Test::Unit::TestCase
assert_equal 301, last_response.status
assert_equal 'https://www.google.com/', last_response.location
end
-
- should 'not redirect SSL requests' do
+
+ should 'redirect SSL requests if hosts do not match' do
get 'https://www.example.org/'
+ assert_equal 301, last_response.status
+ assert_equal 'https://www.google.com/', last_response.location
+ end
+
+ should 'not redirect SSL requests if hosts match' do
+ get 'https://www.google.com'
assert_equal 200, last_response.status
assert_equal 'Hello world!', last_response.body
end

0 comments on commit 5628267

Please sign in to comment.