diff options
author | Jeremy Daer <jeremydaer@gmail.com> | 2015-10-01 20:42:52 -0700 |
---|---|---|
committer | Jeremy Daer <jeremydaer@gmail.com> | 2015-10-01 21:52:57 -0700 |
commit | 28a1a39967ada924179d080b9cd69b3c90f44e4a (patch) | |
tree | 9f0e05dcb3ab35af42fc3db13214046074895653 /actionpack/test/dispatch | |
parent | dd57f60de92833e4f934aad07d8dc5acb5fbbe16 (diff) | |
download | rails-28a1a39967ada924179d080b9cd69b3c90f44e4a.tar.gz rails-28a1a39967ada924179d080b9cd69b3c90f44e4a.tar.bz2 rails-28a1a39967ada924179d080b9cd69b3c90f44e4a.zip |
Response#add_header for adding to multi-valued headers like Vary
Diffstat (limited to 'actionpack/test/dispatch')
-rw-r--r-- | actionpack/test/dispatch/response_test.rb | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/response_test.rb b/actionpack/test/dispatch/response_test.rb index fa29f3a6c4..82cc21b17a 100644 --- a/actionpack/test/dispatch/response_test.rb +++ b/actionpack/test/dispatch/response_test.rb @@ -293,6 +293,65 @@ class ResponseTest < ActiveSupport::TestCase end end +class ResponseHeadersTest < ActiveSupport::TestCase + def setup + @response = ActionDispatch::Response.create + @response.set_header 'Foo', '1' + end + + test 'have_header?' do + assert @response.have_header? 'Foo' + assert_not @response.have_header? 'foo' + assert_not @response.have_header? nil + end + + test 'get_header' do + assert_equal '1', @response.get_header('Foo') + assert_nil @response.get_header('foo') + assert_nil @response.get_header(nil) + end + + test 'set_header' do + assert_equal '2', @response.set_header('Foo', '2') + assert @response.have_header?('Foo') + assert_equal '2', @response.get_header('Foo') + + assert_nil @response.set_header('Foo', nil) + assert @response.have_header?('Foo') + assert_nil @response.get_header('Foo') + end + + test 'delete_header' do + assert_nil @response.delete_header(nil) + + assert_nil @response.delete_header('foo') + assert @response.have_header?('Foo') + + assert_equal '1', @response.delete_header('Foo') + assert_not @response.have_header?('Foo') + end + + test 'add_header' do + # Add a value to an existing header + assert_equal '1,2', @response.add_header('Foo', '2') + assert_equal '1,2', @response.get_header('Foo') + + # Add nil to an existing header + assert_equal '1,2', @response.add_header('Foo', nil) + assert_equal '1,2', @response.get_header('Foo') + + # Add nil to a nonexistent header + assert_nil @response.add_header('Bar', nil) + assert_not @response.have_header?('Bar') + assert_nil @response.get_header('Bar') + + # Add a value to a nonexistent header + assert_equal '1', @response.add_header('Bar', '1') + assert @response.have_header?('Bar') + assert_equal '1', @response.get_header('Bar') + end +end + class ResponseIntegrationTest < ActionDispatch::IntegrationTest test "response cache control from railsish app" do @app = lambda { |env| |