aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/test_case_test.rb
diff options
context:
space:
mode:
authorKir Shatrov <shatrov@me.com>2016-09-21 13:16:59 -0400
committerKir Shatrov <shatrov@me.com>2016-09-21 13:16:59 -0400
commitaa7c4179ff3b0dba6c14e45cecaf853ac9446d41 (patch)
tree6242a8d2b1aa395d83065857fabaf7124500d512 /actionpack/test/controller/test_case_test.rb
parentcf5f55cd30aef0f90300c7c8f333060fe258cd8a (diff)
downloadrails-aa7c4179ff3b0dba6c14e45cecaf853ac9446d41.tar.gz
rails-aa7c4179ff3b0dba6c14e45cecaf853ac9446d41.tar.bz2
rails-aa7c4179ff3b0dba6c14e45cecaf853ac9446d41.zip
Make :as option also set request format (AC::TestCase)
right now you'd have to specify both :as and :format: ``` post :create, params: { foo: "bar" } as: :json, format: :json ```
Diffstat (limited to 'actionpack/test/controller/test_case_test.rb')
-rw-r--r--actionpack/test/controller/test_case_test.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/actionpack/test/controller/test_case_test.rb b/actionpack/test/controller/test_case_test.rb
index 696794a3eb..06e7000bdd 100644
--- a/actionpack/test/controller/test_case_test.rb
+++ b/actionpack/test/controller/test_case_test.rb
@@ -646,6 +646,11 @@ XML
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" }