Sha256: a7afd69d5e113d5b3167ef5b80c919ddeac595666cc012ced7278d0da07bcfde

Contents?: true

Size: 1.29 KB

Versions: 24

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

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

class MiddlewareTest < Minitest::Test
  include Rack::Test::Methods

  def app
    Rails.application
  end

  test "redirects with 302" do
    get "/", {}, "HTTP_USER_AGENT" => "MSIE 6", "HTTP_ACCEPT" => "text/html"
    assert_equal 302, last_response.status
  end

  test "redirects ie6 to upgrade path" do
    get "/", {}, "HTTP_USER_AGENT" => "MSIE 6", "HTTP_ACCEPT" => "text/html"
    follow_redirect!

    assert_equal "UPGRADE: ie6", last_response.body
  end

  test "redirects ie7 to upgrade path" do
    get "/", {}, "HTTP_USER_AGENT" => "MSIE 7", "HTTP_ACCEPT" => "text/html"
    follow_redirect!

    assert_equal "UPGRADE: ie7", last_response.body
  end

  test "redirects ie8 and returns 404" do
    get "/", {}, "HTTP_USER_AGENT" => "MSIE 8", "HTTP_ACCEPT" => "text/html"
    follow_redirect!

    assert_equal 404, last_response.status
  end

  test "redirects ie8 with wildcard http accept" do
    get "/", {}, "HTTP_USER_AGENT" => "MSIE 8", "HTTP_ACCEPT" => "*/*"
    follow_redirect!

    assert_equal 404, last_response.status
  end

  test "ignores non-html requests" do
    get "/", {}, "HTTP_USER_AGENT" => "MSIE 6", "HTTP_ACCEPT" => "image/png"

    assert_equal 200, last_response.status
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
browser-6.2.0 test/middleware_test.rb
browser-6.1.0 test/middleware_test.rb
browser-6.0.0 test/middleware_test.rb
browser-5.3.1 test/middleware_test.rb
browser-5.3.0 test/middleware_test.rb
browser-5.2.0 test/middleware_test.rb
browser-5.1.0 test/middleware_test.rb
browser-5.0.0 test/middleware_test.rb
browser-4.2.0 test/middleware_test.rb
browser-4.1.0 test/middleware_test.rb
browser-4.0.0 test/middleware_test.rb
browser-3.0.3 test/middleware_test.rb
browser-3.0.2 test/middleware_test.rb
browser-3.0.1 test/middleware_test.rb
browser-3.0.0 test/middleware_test.rb
browser-2.7.1 test/middleware_test.rb
browser-2.7.0 test/middleware_test.rb
browser-2.6.1 test/middleware_test.rb
browser-2.6.0 test/middleware_test.rb
browser-2.5.3 test/middleware_test.rb