diff options
author | Yves Senn <yves.senn@gmail.com> | 2013-03-13 11:14:49 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2013-03-13 16:27:47 +0100 |
commit | 8945be464feb8c9ec8c4e7be52e5195f17a1ef5e (patch) | |
tree | a54070d140b34164d06a0a21e6ec433767e72271 /actionpack/test/dispatch | |
parent | b5493c83f5c5ab16878827ae0edf25fbf24825e9 (diff) | |
download | rails-8945be464feb8c9ec8c4e7be52e5195f17a1ef5e.tar.gz rails-8945be464feb8c9ec8c4e7be52e5195f17a1ef5e.tar.bz2 rails-8945be464feb8c9ec8c4e7be52e5195f17a1ef5e.zip |
Http::Headers respects headers that are not prefixed with HTTP_
Diffstat (limited to 'actionpack/test/dispatch')
-rw-r--r-- | actionpack/test/dispatch/header_test.rb | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/actionpack/test/dispatch/header_test.rb b/actionpack/test/dispatch/header_test.rb index 42432510c3..d3fc83ca12 100644 --- a/actionpack/test/dispatch/header_test.rb +++ b/actionpack/test/dispatch/header_test.rb @@ -3,14 +3,16 @@ require 'abstract_unit' class HeaderTest < ActiveSupport::TestCase def setup @headers = ActionDispatch::Http::Headers.new( - "HTTP_CONTENT_TYPE" => "text/plain" + "CONTENT_TYPE" => "text/plain", + "HTTP_REFERER" => "/some/page" ) end def test_each headers = [] @headers.each { |pair| headers << pair } - assert_equal [["HTTP_CONTENT_TYPE", "text/plain"]], headers + assert_equal [["CONTENT_TYPE", "text/plain"], + ["HTTP_REFERER", "/some/page"]], headers end def test_setter @@ -19,19 +21,24 @@ class HeaderTest < ActiveSupport::TestCase end def test_key? - assert @headers.key?('HTTP_CONTENT_TYPE') - assert @headers.include?('HTTP_CONTENT_TYPE') + assert @headers.key?('CONTENT_TYPE') + assert @headers.include?('CONTENT_TYPE') end def test_fetch_with_block assert_equal 'omg', @headers.fetch('notthere') { 'omg' } end - test "content type" do + test "accessing http header" do + assert_equal "/some/page", @headers["Referer"] + assert_equal "/some/page", @headers["referer"] + assert_equal "/some/page", @headers["HTTP_REFERER"] + end + + test "accessing special header" do assert_equal "text/plain", @headers["Content-Type"] assert_equal "text/plain", @headers["content-type"] assert_equal "text/plain", @headers["CONTENT_TYPE"] - assert_equal "text/plain", @headers["HTTP_CONTENT_TYPE"] end test "fetch" do |