aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/best_standards_support_test.rb
blob: 0737c40a39547fdb6bb5332e8b1364072f9e4744 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
require 'abstract_unit'

class BestStandardsSupportTest < ActiveSupport::TestCase
  def test_with_best_standards_support
    _, headers, _ = app(true, {}).call({})
    assert_equal "IE=Edge,chrome=1", headers["X-UA-Compatible"]
  end

  def test_with_builtin_best_standards_support
    _, headers, _ = app(:builtin, {}).call({})
    assert_equal "IE=Edge", headers["X-UA-Compatible"]
  end

  def test_without_best_standards_support
    _, headers, _ = app(false, {}).call({})
    assert_equal nil, headers["X-UA-Compatible"]
  end

  def test_appends_to_app_headers
    app_headers = { "X-UA-Compatible" => "requiresActiveX=true" }
    _, headers, _ = app(true, app_headers).call({})

    expects = "requiresActiveX=true,IE=Edge,chrome=1"
    assert_equal expects, headers["X-UA-Compatible"]
  end

  private

    def app(type, headers)
      app = proc { [200, headers, "response"] }
      ActionDispatch::BestStandardsSupport.new(app, type)
    end

end