diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2016-02-10 22:39:29 +0100 |
---|---|---|
committer | Kasper Timm Hansen <kaspth@gmail.com> | 2016-02-10 22:39:29 +0100 |
commit | 33257d15ad5239260747fcefc8528efe21fbe02b (patch) | |
tree | 819501618ffa09bb56fb968667abcd0b3828df0a /actionpack/CHANGELOG.md | |
parent | 391061a30d7ab2923ea342048fe643469de3f1a9 (diff) | |
parent | c85b17773e943a227d6b559736aeb40a3b214b71 (diff) | |
download | rails-33257d15ad5239260747fcefc8528efe21fbe02b.tar.gz rails-33257d15ad5239260747fcefc8528efe21fbe02b.tar.bz2 rails-33257d15ad5239260747fcefc8528efe21fbe02b.zip |
Merge pull request #23597 from kaspth/integration-response-parsing
Add `response.parsed_body` to Integration Tests
Diffstat (limited to 'actionpack/CHANGELOG.md')
-rw-r--r-- | actionpack/CHANGELOG.md | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index 93e598e493..bf964d06e9 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -1,3 +1,41 @@ +* Add request encoding and response parsing to integration tests. + + What previously was: + + ```ruby + require 'test_helper' + + class ApiTest < ActionDispatch::IntegrationTest + test 'creates articles' do + assert_difference -> { Article.count } do + post articles_path(format: :json), + params: { article: { title: 'Ahoy!' } }.to_json, + headers: { 'Content-Type' => 'application/json' } + end + + assert_equal({ id: Article.last.id, title: 'Ahoy!' }, JSON.parse(response.body)) + end + end + ``` + + Can now be written as: + + ```ruby + require 'test_helper' + + class ApiTest < ActionDispatch::IntegrationTest + test 'creates articles' do + assert_difference -> { Article.count } do + post articles_path, { article: { title: 'Ahoy!' } }, as: :json + end + + assert_equal({ id: Article.last.id, title: 'Ahoy!' }, response.parsed_body) + end + end + ``` + + *Kasper Timm Hansen* + * Add image/svg+xml as a default mime type. *DHH* |