New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AM::Serializers::JSON#as_json method for timestamps #31503

Merged
merged 1 commit into from Aug 11, 2018

Conversation

Projects
None yet
4 participants
@bogdan
Contributor

bogdan commented Dec 19, 2017

According to doc the method should return
non-json compatible types as strings.

The original idea behind as_json is that:

object.as_json == JSON.parse(object.to_json)

This patch fixes the compatibility for types that are not supported by JSON.
Also this patch makes Hash#as_json compatible AR::Base#as_json:

{created_at: Time.now}.as_json # => {"created_at": "2010-10-13T22:05:30.000-07:00"}
@rails-bot

This comment has been minimized.

Show comment
Hide comment
@rails-bot

rails-bot Dec 19, 2017

r? @eileencodes

(@rails-bot has picked a reviewer for you, use r? to override)

rails-bot commented Dec 19, 2017

r? @eileencodes

(@rails-bot has picked a reviewer for you, use r? to override)

Fix AM::Serializers::JSON#as_json method for timestamps
According to doc the method should return
non-json compatible types as strings.
@bogdan

This comment has been minimized.

Show comment
Hide comment
@bogdan

bogdan Feb 23, 2018

Contributor

@eileencodes any thoughts on this bugfix?

Contributor

bogdan commented Feb 23, 2018

@eileencodes any thoughts on this bugfix?

@eileencodes eileencodes merged commit 09e1452 into rails:master Aug 11, 2018

2 checks passed

codeclimate All good!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

bogdanvlviv added a commit to bogdanvlviv/rails that referenced this pull request Aug 11, 2018

Fix test failure
```
...
(snip)
............F
Failure:
JsonSerializationTest#test_as_json_should_return_a_hash_if_include_root_
in_json_is_true [/home/travis/build/rails/rails/activemodel/test/cases/serializers/json_serialization_test.rb:145]:
Expected: 2006-08-01 00:00:00 UTC
  Actual: "2006-08-01T00:00:00.000Z"
rails test home/travis/build/rails/rails/activemodel/test/cases/serializers/json_serialization_test.rb:136
(snip)
...
```

Related to rails#31503

@bogdanvlviv bogdanvlviv referenced this pull request Aug 11, 2018

Merged

Fix test failure #33588

@bogdanvlviv

This comment has been minimized.

Show comment
Hide comment
@bogdanvlviv

bogdanvlviv Aug 11, 2018

Contributor

How about adding changelog entry for this change?

Contributor

bogdanvlviv commented Aug 11, 2018

How about adding changelog entry for this change?

bogdanvlviv added a commit to bogdanvlviv/rails that referenced this pull request Aug 12, 2018

eileencodes added a commit that referenced this pull request Aug 12, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment