Skip to content

Conversation

@hashrocketeer
Copy link

  • Add destroyed? method
  • Do not clear resource attributes
  • Return false on persisted? after being destroyed
  • Return false on new_record? after being destroyed

* Add `destroyed?` method
* Return false on `persisted?`
* Do not clear resource attributes

Co-authored-by: Gabriel Reis <gabriel@hashrocket.com>
else
self.attributes.clear
mark_as_destroyed!
self.relationships.attributes.clear
Copy link
Member

Choose a reason for hiding this comment

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

if we don't want to clear attributes after destroy, why we should clear relationships?

Co-authored-by: Mary Lee <mary.lee@hashrocket.com>
Co-authored-by: Gabriel Reis <gabriel@hashrocket.com>
@senid231 senid231 requested a review from gaorlov October 26, 2018 08:19
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.

That looks great! Thanks a ton for the PR and the work.

user = users.first
assert(user.persisted?)
assert_equal(false, user.new_record?)
assert_equal(false, user.destroyed?)
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can also do refute user.new_record?, but it really doesn't matter

Copy link
Author

Choose a reason for hiding this comment

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

We can change it if you'd like; we were just trying to follow the style of the existing tests. Do you want us to update?

Copy link

@workgena workgena Oct 26, 2018

Choose a reason for hiding this comment

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

Hi 👋, recently I played with Rubocop. It suggests to use ActiveSupport method assert_not

assert_not user.new_record?

PS: more than one way of doing the same thing 😏 Its up to commits author, what to use.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@hashrocketeer, nah. Thanks again for the contribution! I'll push out a new version with your code by eod.

@gaorlov gaorlov merged commit 147ec71 into JsonApiClient:master Oct 26, 2018
@gaorlov
Copy link
Collaborator

gaorlov commented Oct 26, 2018

@hashrocketeer 1.6.4 is live. thanks again for your contribution!

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.

4 participants