Sha256: 709f5520a09c122d39d6ae150aab463ac5747f8a35f9629efdea890a93000886

Contents?: true

Size: 924 Bytes

Versions: 47

Compression:

Stored size: 924 Bytes

Contents

# frozen_string_literal: true

require "abstract_unit"

class MetalControllerInstanceTests < ActiveSupport::TestCase
  class SimpleController < ActionController::Metal
    def hello
      self.response_body = "hello"
    end
  end

  def test_response_does_not_have_default_headers
    original_default_headers = ActionDispatch::Response.default_headers

    ActionDispatch::Response.default_headers = {
      "X-Frame-Options" => "DENY",
      "X-Content-Type-Options" => "nosniff",
      "X-XSS-Protection" => "1;"
    }

    response_headers = SimpleController.action("hello").call(
      "REQUEST_METHOD" => "GET",
      "rack.input" => -> {}
    )[1]

    assert_not response_headers.key?("X-Frame-Options")
    assert_not response_headers.key?("X-Content-Type-Options")
    assert_not response_headers.key?("X-XSS-Protection")
  ensure
    ActionDispatch::Response.default_headers = original_default_headers
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
jets-1.5.6 vendor/rails/actionpack/test/controller/metal_test.rb
jets-1.5.5 vendor/rails/actionpack/test/controller/metal_test.rb
jets-1.5.4 vendor/rails/actionpack/test/controller/metal_test.rb
jets-1.5.3 vendor/rails/actionpack/test/controller/metal_test.rb
jets-1.5.2 vendor/rails/actionpack/test/controller/metal_test.rb
jets-1.5.1 vendor/rails/actionpack/test/controller/metal_test.rb
jets-1.5.0 vendor/rails/actionpack/test/controller/metal_test.rb