Skip to content

Commit

Permalink
Add request encoding and response parsing to changelog.
Browse files Browse the repository at this point in the history
Forgot to add this in the original pull request. No biggie, just show
some examples.
  • Loading branch information
kaspth committed Feb 10, 2016
1 parent eee3534 commit c85b177
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions 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*
Expand Down

0 comments on commit c85b177

Please sign in to comment.