Permalink
Browse files

Merge pull request #26573 from kirs/action-controller-as-format

Make :as option also set request format (AC::TestCase)
  • Loading branch information...
rafaelfranca committed Sep 27, 2016
2 parents f2f6a39 + aa7c417 commit ebcd9650153ae693939550a6e08898345b986023
Showing with 9 additions and 4 deletions.
  1. +4 −4 actionpack/lib/action_controller/test_case.rb
  2. +5 −0 actionpack/test/controller/test_case_test.rb
@@ -498,10 +498,6 @@ def process(action, *args)
parameters ||= {}
if format
parameters[:format] = format
end
@html_document = nil
cookies.update(@request.cookies)
@@ -521,6 +517,10 @@ def process(action, *args)
format ||= as
end
if format
parameters[:format] = format
end
parameters = parameters.symbolize_keys
generated_extras = @routes.generate_extras(parameters.merge(controller: controller_class_name, action: action.to_s))
@@ -646,6 +646,11 @@ def test_using_as_json_sets_request_content_type_to_json
assert_equal 2, @request.request_parameters[:num_value]
end
def test_using_as_json_sets_format_json
post :render_body, params: { bool_value: true, str_value: "string", num_value: 2 }, as: :json
assert_equal "json", @request.format
end
def test_mutating_content_type_headers_for_plain_text_files_sets_the_header
@request.headers["Content-Type"] = "text/plain"
post :render_body, params: { name: "foo.txt" }

0 comments on commit ebcd965

Please sign in to comment.