Skip to content

Commit

Permalink
Merge pull request #25757 from monkey-mas/add-tests-for-response_test
Browse files Browse the repository at this point in the history
Add tests for 1xx, 204 and 304 responses to response_test.rb
  • Loading branch information
guilleiguaran committed Jul 10, 2016
2 parents 27a0716 + bddf83b commit db1582a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions actionpack/test/dispatch/response_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,26 @@ def test_only_set_charset_still_defaults_to_text_html
}, headers)
end

test "content length" do
[100, 101, 102, 204].each do |c|
@response = ActionDispatch::Response.new
@response.status = c.to_s
@response.set_header "Content-Length", "0"
_, headers, _ = @response.to_a
assert !headers.has_key?("Content-Length"), "#{c} must not have a Content-Length header field"
end
end

test "does not contain a message-body" do
[100, 101, 102, 204, 304].each do |c|
@response = ActionDispatch::Response.new
@response.status = c.to_s
@response.body = "Body must not be included"
_, _, body = @response.to_a
assert_empty body, "#{c} must not have a message-body but actually contains #{body}"
end
end

test "content type" do
[204, 304].each do |c|
@response = ActionDispatch::Response.new
Expand Down

0 comments on commit db1582a

Please sign in to comment.