-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Improve readability of relationships test #1904
Improve readability of relationships test #1904
Conversation
3e6a79d
to
0bd17a6
Compare
1f9dfaa
to
dd8e147
Compare
end | ||
|
||
def test_take2_relationship_simple_link | ||
expected = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
example of tests that test at very different levels
- test_relationship_simple_link
- test_take2_relationship_simple_link
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the purpose of all the take2 tests? other than seemingly having more setup and logic to assert
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merging two test files; need to disambiguate
was there anything left to do on this other than the rebase? |
I accidentally introduced the duplication when merging rails-api#1543 (comment) and they've evolved separately since then. They both have some value and need to be combined.
dd8e147
to
baa4716
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ready for review
6ebdaee
to
35f38dc
Compare
5371c40
to
e7e0126
Compare
e7e0126
to
4b72742
Compare
|
||
def test_relationship_with_nil_serializer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a relationship with a nil serializer that isn't using virtual values (i.e. doesn't need a serializer in the firsts place) isn't a supported use case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In practice, AMS will try to call as_json
on the data object
model_attributes = { blog: Blog.new(id: 1) } | ||
relationship_name = :blog | ||
model = new_model(model_attributes) | ||
actual = build_serializer_and_serialize_relationship(model, relationship_name) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like this pattern, of defining the serializer for test in the test itself
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall I really like how consistent the tests are now. :-)
#1902 was not enough, it appears