Permalink
Browse files

Fix ActionDispatch::Request#formats when HTTP_ACCEPT header is empty …

…string
  • Loading branch information...
1 parent ee314a5 commit bebb02fd1c5ea0e8da9fb61eefcbb6ec8b9ab11f @soylent soylent committed Jan 17, 2013
@@ -122,7 +122,7 @@ def negotiate_mime(order)
def valid_accept_header
(xhr? && (accept || content_mime_type)) ||
- (accept && accept !~ BROWSER_LIKE_ACCEPTS)
+ (accept.present? && accept !~ BROWSER_LIKE_ACCEPTS)
end
def use_accept_header
@@ -587,6 +587,10 @@ def url_for(options = {})
request.expects(:parameters).at_least_once.returns({})
assert_equal [Mime::HTML], request.formats
+ request = stub_request 'HTTP_ACCEPT' => ''
+ request.expects(:parameters).at_least_once.returns({})
+ assert_equal [Mime::HTML], request.formats
+
request = stub_request 'CONTENT_TYPE' => 'application/xml; charset=UTF-8',
'HTTP_X_REQUESTED_WITH' => "XMLHttpRequest"
request.expects(:parameters).at_least_once.returns({})

0 comments on commit bebb02f

Please sign in to comment.