-
Notifications
You must be signed in to change notification settings - Fork 25
Properly call destroy method so after_commit callback is called. #67
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
Properly call destroy method so after_commit callback is called. #67
Conversation
302777a to
0986c14
Compare
|
I fixed merge conflicts. |
test/test_helper.rb
Outdated
|
|
||
| attr_reader :after_commited | ||
|
|
||
| def foo |
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 PR @nashby. Could you change the name of this method to something more descriptive. This will provide insight into why we're including this in the test_helper.rb down the line.
Something like set_after_committed_flag should do.
0986c14 to
0488f44
Compare
|
@michaeldupuisjr thanks for the review! I've updated PR. |
| comment = Comment.create | ||
| comment.destroy | ||
|
|
||
| comment.after_committed.must_equal true |
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.
This spec does not demonstrate that destroying objects fires the after_commit callback. Indeed, it will still pass if line 266 is removed altogether. This is because the #create also runs the after_commit callbacks, so the flag is already set before #destroy is even run.
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.
hmm, but I have after_commit with on: :destroy option. It shouldn't be called on create, should 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.
Yes, I overlooked that; you are absolutely correct.
deletes original comment
|
Great minds think alike! 😉 It seems that I have duplicated this effort in #71. |
|
Sorry @nashby but it looks like this branch may need to be rebased. I'll get this merged in once tests are green. |
0488f44 to
ae82efb
Compare
|
@michaeldupuisjr no problem. I rebased. Let's wait for specs to be 💚 . |
I couldn't find an easy way to test that method is called in minitest though.
fixes #56