test/noie6_test.rb in sant0sk1-rack-noie6-1.0.1 vs test/noie6_test.rb in sant0sk1-rack-noie6-1.1.0
- old
+ new
@@ -18,18 +18,37 @@
response = request.get('/', {'HTTP_USER_AGENT' => 'MSIE 6.0' })
assert_equal 301, response.status
assert_equal response.location, 'http://slashdot.org'
end
+ def test_redirects_to_where_it_should_if_user_specified_minimum_not_met
+ request = Rack::MockRequest.new(Rack::NoIE6.new(TestApp.new, {:redirect => 'http://slashdot.org', :minimum => 6.0}))
+ response = request.get('/', {'HTTP_USER_AGENT' => 'Mozilla/4.0 (compatible; MSIE 5.5b1; Mac_PowerPC)' })
+ assert_equal 301, response.status
+ assert_equal response.location, 'http://slashdot.org'
+ end
+
def test_redirects_to_local_urls
request = Rack::MockRequest.new(Rack::NoIE6.new(TestApp.new, {:redirect => '/foo'}))
response = request.get('/foo', {'HTTP_USER_AGENT' => 'MSIE 6.0' })
assert_equal "Hi Internets!", response.body
end
def test_allows_if_not_ie6
request = Rack::MockRequest.new(Rack::NoIE6.new(TestApp.new, {:redirect => 'http://slashdot.org'}))
response = request.get('/', {'HTTP_USER_AGENT' => 'Mozilla/5.0'})
+ assert_equal "Hi Internets!", response.body
+ end
+
+ def test_allows_if_UA_version_greater_than_minimum
+ request = Rack::MockRequest.new(Rack::NoIE6.new(TestApp.new, {:redirect => 'http://slashdot.org'}))
+ response = request.get('/', {'HTTP_USER_AGENT' => 'Mozilla/4.0 (compatible; MSIE 8.0; Windows XP)'})
+ assert_equal "Hi Internets!", response.body
+ end
+
+ def test_allows_if_no_UA_version_no_available
+ request = Rack::MockRequest.new(Rack::NoIE6.new(TestApp.new, {:redirect => 'http://slashdot.org'}))
+ response = request.get('/', {'HTTP_USER_AGENT' => 'Mozilla/4.0 (compatible; MSIE l4me; Windows XP)'})
assert_equal "Hi Internets!", response.body
end
def test_allows_if_no_user_agent_specified
request = Rack::MockRequest.new(Rack::NoIE6.new(TestApp.new, {:redirect => 'http://slashdot.org'}))
\ No newline at end of file