1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Unknown :format param should result in empty request.formats

This commit is contained in:
Jeremy Kemper 2009-11-08 12:12:45 -08:00
parent 103b29831e
commit a595abff21
2 changed files with 5 additions and 1 deletions

View file

@ -167,7 +167,7 @@ module ActionDispatch
@env["action_dispatch.request.formats"] ||= @env["action_dispatch.request.formats"] ||=
if parameters[:format] if parameters[:format]
[Mime[parameters[:format]]] Array.wrap(Mime[parameters[:format]])
elsif xhr? || (accept && !accept.include?(?,)) elsif xhr? || (accept && !accept.include?(?,))
accepts accepts
else else

View file

@ -432,6 +432,10 @@ class RequestTest < ActiveSupport::TestCase
request = stub_request request = stub_request
request.expects(:parameters).at_least_once.returns({ :format => :txt }) request.expects(:parameters).at_least_once.returns({ :format => :txt })
assert_equal with_set(Mime::TEXT), request.formats assert_equal with_set(Mime::TEXT), request.formats
request = stub_request
request.expects(:parameters).at_least_once.returns({ :format => :unknown })
assert request.formats.empty?
end end
test "negotiate_mime" do test "negotiate_mime" do