Sha256: 2fb0ba7fa6986b9bf9a234b4201b82437227613949304adc24503291af6f24de

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

require "test_helper"
require "browser/rails"
require "sample_app"

class MiddlewareTest < Test::Unit::TestCase
  include Rack::Test::Methods

  def app
    Rails.application
  end

  def test_redirect_uses_302
    get "/", {}, {"HTTP_USER_AGENT" => "MSIE 6", "HTTP_ACCEPT" => "text/html"}
    assert_equal 302, last_response.status
  end

  def test_redirect_ie6_to_upgrade_path
    get "/", {}, {"HTTP_USER_AGENT" => "MSIE 6", "HTTP_ACCEPT" => "text/html"}
    follow_redirect!

    assert_equal "UPGRADE: ie6", last_response.body
  end

  def test_redirect_ie7_to_upgrade_path
    get "/", {}, {"HTTP_USER_AGENT" => "MSIE 7", "HTTP_ACCEPT" => "text/html"}
    follow_redirect!

    assert_equal "UPGRADE: ie7", last_response.body
  end

  def test_redirect_ie8_and_404
    get "/", {}, {"HTTP_USER_AGENT" => "MSIE 8", "HTTP_ACCEPT" => "text/html"}
    follow_redirect!

    assert_equal 404, last_response.status
  end

  def test_ignores_non_html_requests
    get "/", {}, {"HTTP_USER_AGENT" => "MSIE 6", "HTTP_ACCEPT" => "image/png"}

    assert_equal 200, last_response.status
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
browser-0.4.0 test/middleware_test.rb
browser-0.3.2 test/middleware_test.rb
browser-0.3.1 test/middleware_test.rb