提交 ebcd9650 编写于 作者: R Rafael França 提交者: GitHub

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

Make :as option also set request format (AC::TestCase)
......@@ -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" }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册