-
Notifications
You must be signed in to change notification settings - Fork 181
Remove clear_changes_information in relations #317
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
Conversation
fzf
commented
Oct 31, 2018
- Enables passing relationships in create calls
- Existing tests were not working due to stub request matching
- Includes relationships in as_json_api method
* Enables passing relationships in create calls * Existing tests were not working due to stub request matching * Includes relationships in as_json_api method
c913871
to
894779b
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.
Thanks for the contribution! Can you explain the thinking behind rearranging the tests and the whitespace changes? Is it relevant to the PR?
@gaorlov I noted on #307 currently the mock does not trigger and the extra paramters are not sent with the current implementation. The reformatting is to encapsulate the setup mock in a describe block and changes that were necessary to actually mock the web request. Let me know if you have any other questions. |
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 #318 I've added tests to ensure proper work of relationships dirty
"id"=>"9" | ||
} | ||
} | ||
}, |
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 don't think that in this case relationships should be serialized
#as_json_api
is used for gathering a payload that will be sent to server
and we should not add to payload relationships that weren't changed by user
example:
post = Post.includes(:author).find(1)
post.title = 'changed title'
post.save # author relationship should not be present in payload
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 can agree with that, this part was more of a side effect of removing the clear_changes_information, if there is another solution that allows relationships to be passed on create and does not change this I am all for it.
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.
Also, #318 does not address the issues with creation
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.
@fzf can you please provide some code snippet that explains issue with creation that you have encountered?
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.
Relationship data is never actually sent, it is cleared before it can be sent. Here is a spec showing that it is a false positive. #319
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.
@fzf I agree that some tests have mistakes and some mocks were written incorrect, but I don't think that logic shouldn't be changed. |