-
Notifications
You must be signed in to change notification settings - Fork 62
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
Resubmitting #14 - Adding callbacks for draft creation, update, and destroy #20
Conversation
Hey @chrisdpeters, thanks for merging #21 and #23. If you'd like, I can rebase this and make sure it's a clean fast forward merge. |
@npafundi No worries. I will be releasing v0.3.4 with your bug fixes soon. These new callbacks will go in v0.4. |
758ac02
to
893bbc7
Compare
Nine callbacks have been added via ActiveModel::Callbacks: (before | around | after)_draft_creation (before | around | after)_draft_update (before | around | after)_draft_destroy These work very similarly to traditional ActiveRecord callbacks, (e.g. `before_create`), except they are triggered when working with drafts. This commit simply wraps the `draft_creation`, `draft_update`, and `draft_destroy` methods with a `run_callbacks` call. Any callbacks defined on models which have drafts will be run as defined. We only extend models which have drafts, to avoid further cluttering models.
Added 25 specs to test each of the nine draft callbacks. before_draft_creation, around_draft_creation, after_draft_creation before_draft_update, around_draft_update, after_draft_update before_draft_destroy, around_draft_destroy, after_draft_destroy The `Talkative` model contains a few attributes which are modified via these callbacks. The tests check that the attributes are modified correctly, and also check that they're called at the appropriate times.
@chrisdpeters I rebased this branch to match master again. Are you still considering pulling this in? |
@npafundi Thank you for the rebase. Yes, I would like to get this merged and released within a week or 2. I wanted to spend some time reviewing the tests just to make sure I understand everything fully. I'm sure it's fairly straightforward. |
@npafundi Heck, let's merge now. This is next on the list. |
Resubmitting #14 - Adding callbacks for draft creation, update, and destroy
Thanks @chrisdpeters! Happy to explain anything, and if I'm missing any tests we can definitely add more. |
See discussion and comments at #14