rails/actionpack/test
Jon Moss 773f71c8a0 Don't error on an empty CONTENT_TYPE
This commit prevents a possible issue wherein an empty CONTENT_TYPE
header is sent in a request to a Rails application, and then `request.content_mime_type`
would return `nil`. This is because the `has_content_type?` guard method
was not properly checking the validity of a request's content type; it
was only checking to see whether or not the header existed, not whether
it had a value stored inside.

Relatedly, after an internal discussion, it was determined that the
`has_content_type?` method is not meant to be part of the public API,
and is therefore changed to a `:nodoc:` method in this commit.

The test for this behavior is a little bit ugly, for two reasons. One is
that it was difficult to determine where to place the test... I figured
the best place would be with the rest of the ParamsWrapper stuff, since
that's where the original issue was. Also, we have to do some fancy
footwork in calling `dispatch` on the test's controller manually... this
is because `ActionController::TestCase` will throw an error if you try
and pass in a nil content type, which is exactly what we are trying to
test here... Because of that, we have to manually call in to the
controller, and bypass the `post` request helper.

Fixes #26912.

This is a regression in behavior between Rails versions 4.2.x and 5.0.x,
which was introduced via [this commit](a9f28600e9).
2016-11-10 14:33:16 -05:00
..
abstract Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
assertions Improve assert_response helper 2016-09-14 11:30:09 -04:00
controller Don't error on an empty CONTENT_TYPE 2016-11-10 14:33:16 -05:00
dispatch Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
fixtures Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
journey Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
lib/controller Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
routing applies new string literal convention in actionpack/test 2016-08-06 18:54:50 +02:00
tmp
abstract_unit.rb Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00