Skip to content

Commit ec08bfc

Browse files
committed
Merge pull request rails#1324 from dmathieu/no_error_on_invalid_format
Don't raise an exception if the format isn't recognized
2 parents badc72f + 16571f9 commit ec08bfc

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Diff for: actionpack/lib/action_controller/metal/instrumentation.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def process_action(*args)
1919
:controller => self.class.name,
2020
:action => self.action_name,
2121
:params => request.filtered_parameters,
22-
:format => request.format.ref,
22+
:format => request.format.try(:ref),
2323
:method => request.method,
2424
:path => (request.fullpath rescue "unknown")
2525
}

Diff for: actionpack/test/controller/mime_responds_test.rb

+6
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,12 @@ def test_format_with_custom_response_type_and_request_headers
498498
assert_equal '<html><div id="iphone">Hello iPhone future from iPhone!</div></html>', @response.body
499499
assert_equal "text/html", @response.content_type
500500
end
501+
502+
def test_invalid_format
503+
get :using_defaults, :format => "invalidformat"
504+
assert_equal " ", @response.body
505+
assert_equal "text/html", @response.content_type
506+
end
501507
end
502508

503509
class RespondWithController < ActionController::Base

0 commit comments

Comments
 (0)