Skip to content

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

Closed

Conversation

fzf
Copy link
Contributor

@fzf 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
@fzf fzf force-pushed the remove_clear_changes_information branch from c913871 to 894779b Compare October 31, 2018 20:56
Copy link
Collaborator

@gaorlov gaorlov left a 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?

@fzf
Copy link
Contributor Author

fzf commented Nov 1, 2018

@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.

Copy link
Member

@senid231 senid231 left a 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"
}
}
},
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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

Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#319 had a naming issue you can see the failure now @senid231

@senid231
Copy link
Member

senid231 commented Nov 1, 2018

@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.

@senid231
Copy link
Member

senid231 commented Nov 8, 2018

@fzf thanks for clarifying this.
I've created PR #320 with correct way of fixing this issue.

Please refer to it if you have any questions.

@senid231 senid231 closed this Nov 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants