Skip to content
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

Merged
merged 3 commits into from
Nov 11, 2015

Conversation

npafundi
Copy link
Contributor

@npafundi npafundi commented Apr 8, 2015

See discussion and comments at #14

@npafundi
Copy link
Contributor Author

npafundi commented May 5, 2015

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.

@chrisdpeters
Copy link
Collaborator

@npafundi No worries. I will be releasing v0.3.4 with your bug fixes soon. These new callbacks will go in v0.4.

@chrisdpeters chrisdpeters added this to the 0.4.0 milestone May 5, 2015
@npafundi npafundi force-pushed the callbacks branch 2 times, most recently from 758ac02 to 893bbc7 Compare May 20, 2015 16:54
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.
@npafundi
Copy link
Contributor Author

@chrisdpeters I rebased this branch to match master again. Are you still considering pulling this in?

@chrisdpeters
Copy link
Collaborator

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

@chrisdpeters
Copy link
Collaborator

@npafundi Heck, let's merge now. This is next on the list.

chrisdpeters added a commit that referenced this pull request Nov 11, 2015
Resubmitting #14 - Adding callbacks for draft creation, update, and destroy
@chrisdpeters chrisdpeters merged commit 8212240 into copasetickid:master Nov 11, 2015
@npafundi
Copy link
Contributor Author

Thanks @chrisdpeters! Happy to explain anything, and if I'm missing any tests we can definitely add more.

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.

2 participants