Permalink
Browse files

move header allocation to a helper method

I'm going to change the constructor, so it's easier to do it in one
place.
  • Loading branch information...
tenderlove committed Aug 20, 2015
1 parent 95cb2e3 commit c6cfcc6124fdef4df3a406f389ba32be486cd437
Showing with 9 additions and 5 deletions.
  1. +9 −5 actionpack/test/dispatch/header_test.rb
@@ -1,15 +1,19 @@
require "abstract_unit"
class HeaderTest < ActiveSupport::TestCase
def make_headers(hash)
ActionDispatch::Http::Headers.new hash
end
setup do
@headers = ActionDispatch::Http::Headers.new(
@headers = make_headers(
"CONTENT_TYPE" => "text/plain",
"HTTP_REFERER" => "/some/page"
)
end
test "#new does not normalize the data" do
headers = ActionDispatch::Http::Headers.new(
headers = make_headers(
"Content-Type" => "application/json",
"HTTP_REFERER" => "/some/page",
"Host" => "http://test.com")
@@ -108,7 +112,7 @@ class HeaderTest < ActiveSupport::TestCase
end
test "env variables with . are not modified" do
headers = ActionDispatch::Http::Headers.new
headers = make_headers({})
headers.merge! "rack.input" => "",
"rack.request.cookie_hash" => "",
"action_dispatch.logger" => ""
@@ -119,7 +123,7 @@ class HeaderTest < ActiveSupport::TestCase
end
test "symbols are treated as strings" do
headers = ActionDispatch::Http::Headers.new
headers = make_headers({})
headers.merge!(:SERVER_NAME => "example.com",
"HTTP_REFERER" => "/",
:Host => "test.com")
@@ -130,7 +134,7 @@ class HeaderTest < ActiveSupport::TestCase
test "headers directly modifies the passed environment" do
env = {"HTTP_REFERER" => "/"}
headers = ActionDispatch::Http::Headers.new(env)
headers = make_headers(env)
headers['Referer'] = "http://example.com/"
headers.merge! "CONTENT_TYPE" => "text/plain"
assert_equal({"HTTP_REFERER"=>"http://example.com/",

0 comments on commit c6cfcc6

Please sign in to comment.