diff options
Diffstat (limited to 'actionpack/CHANGELOG.md')
-rw-r--r-- | actionpack/CHANGELOG.md | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index 921aff300f..931313612c 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -13,7 +13,7 @@ headers: { 'Content-Type' => 'application/json' } end - assert_equal({ id: Article.last.id, title: 'Ahoy!' }, JSON.parse(response.body)) + assert_equal({ 'id' => Article.last.id, 'title' => 'Ahoy!' }, JSON.parse(response.body)) end end ``` @@ -26,13 +26,22 @@ class ApiTest < ActionDispatch::IntegrationTest test 'creates articles' do assert_difference -> { Article.count } do - post articles_path, { article: { title: 'Ahoy!' } }, as: :json + post articles_path, params: { article: { title: 'Ahoy!' } }, as: :json end - assert_equal({ id: Article.last.id, title: 'Ahoy!' }, response.parsed_body) + assert_equal({ 'id' => Article.last.id, 'title' => 'Ahoy!' }, response.parsed_body) end end ``` + + Passing `as: :json` to integration test request helpers will set the format, + content type and encode the parameters as JSON. + + Then on the response side, `parsed_body` will parse the body according to the + content type the response has. + + Currently JSON is the only supported MIME type. Add your own with + `ActionDispatch::IntegrationTest.register_encoder`. *Kasper Timm Hansen* @@ -42,10 +51,10 @@ ## Rails 5.0.0.beta2 (February 01, 2016) ## -* Add `-g` and `-c` options to `bin/rake routes`. These options return the url `name`, `verb` and +* Add `-g` and `-c` options to `bin/rails routes`. These options return the url `name`, `verb` and `path` field that match the pattern or match a specific controller. - Deprecate `CONTROLLER` env variable in `bin/rake routes`. + Deprecate `CONTROLLER` env variable in `bin/rails routes`. See #18902. |