-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Stop calling perform! as Spree::Refund after_create callback #3641
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kennyadsl
added
type:enhancement
Proposed or newly added feature
changelog:solidus_core
Changes to the solidus_core gem
labels
May 26, 2020
houndci-bot
reviewed
May 26, 2020
aldesantis
requested changes
May 27, 2020
kennyadsl
force-pushed
the
kennyadsl/restore-1415
branch
from
May 27, 2020 16:35
8372729
to
b024a50
Compare
aldesantis
approved these changes
May 28, 2020
jarednorman
requested changes
May 28, 2020
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.
One small thing, but otherwise I think this looks good.
core/app/models/spree/reimbursement_type/reimbursement_helpers.rb
Outdated
Show resolved
Hide resolved
To provide users more control over how they work with refunds, we want to be able to create a refund withouth implicitly performing the transaction. This change moves perform! to a public method; users must now explicitly call perform! on a refund.
We need to explicitly call #perform! on a refund for the transaction to occur, now that the after_create callback has been removed.
Previously the #cancel method relied on the after_create callback performing the refund. Now it is explicitly called after the refund is built.
kennyadsl
force-pushed
the
kennyadsl/restore-1415
branch
from
May 29, 2020 11:45
b024a50
to
b04b2d1
Compare
We can't just stop calling this callback or we are going to break applications when it's defined code like: Spree::Refund.create(attrs: ...) since it currently relies on also calling perform! as well. With this code, the old behavior is still there but we are asking users to update their code to transition to the new behavior, which is something like: Spree::Refund.create(attrs: ..., perform_after_create: false).perform! The two extra callbacks are needed to: - set_perform_after_create_default: prints the deprecation message only when creating the instance, otherwise it will be printed also when calling perform! on a good instance. Also, it sets the deafult to true when the attribute is not passed, which means that code has not been updated yet. - clear_perform_after_create: this callback is needed to clean the instance, after this process ends, otherwise each call of perform! after the callbacks execution could not be executed if the instance was created with perform_after_create: false. Specs needed some seriuos refactor to reflect this new architecture but they look cleaner now. Co-Authoring the commit since the initial code has been taken from solidusio#3181. Co-authored-by: Angel Perez <aitbw@users.noreply.github.com>
kennyadsl
force-pushed
the
kennyadsl/restore-1415
branch
from
May 29, 2020 12:02
b04b2d1
to
3d6f510
Compare
jarednorman
approved these changes
May 29, 2020
This was referenced May 29, 2020
5 tasks
kennyadsl
added a commit
to solidusio/solidus_stripe
that referenced
this pull request
Jan 22, 2021
After solidusio/solidus#3641 it's requested to create and perform refunds in two different operations. This commit aligns the code to the new standard.
kennyadsl
added a commit
to solidusio/solidus_stripe
that referenced
this pull request
Jan 22, 2021
After solidusio/solidus#3641 it's requested to create and perform refunds in two different operations. This commit aligns the code to the new standard. Co-authored-by: Rainer Dema <rainerdema@users.noreply.github.com>
kennyadsl
added a commit
to solidusio/solidus_stripe
that referenced
this pull request
Jan 26, 2021
After solidusio/solidus#3641 it's requested to create and perform refunds in two different operations. This commit aligns the code to the new standard. Co-authored-by: Rainer Dema <rainerdema@users.noreply.github.com>
kennyadsl
added a commit
to solidusio/solidus_stripe
that referenced
this pull request
Jan 27, 2021
After solidusio/solidus#3641 it's requested to create and perform refunds in two different operations. This commit aligns the code to the new standard. Co-authored-by: Rainer Dema <rainerdema@users.noreply.github.com>
kennyadsl
added a commit
to solidusio/solidus_stripe
that referenced
this pull request
Jan 28, 2021
After solidusio/solidus#3641 it's requested to create and perform refunds in two different operations. This commit aligns the code to the new standard. Co-authored-by: Rainer Dema <rainerdema@users.noreply.github.com>
kennyadsl
added a commit
to solidusio/solidus_stripe
that referenced
this pull request
Jan 28, 2021
After solidusio/solidus#3641 it's requested to create and perform refunds in two different operations. This commit aligns the code to the new standard. Co-authored-by: Rainer Dema <rainerdema@users.noreply.github.com>
kennyadsl
added a commit
to solidusio/solidus_stripe
that referenced
this pull request
Jan 29, 2021
After solidusio/solidus#3641 it's requested to create and perform refunds in two different operations. This commit aligns the code to the new standard. Co-authored-by: Rainer Dema <rainerdema@users.noreply.github.com>
kennyadsl
added a commit
to solidusio/solidus_stripe
that referenced
this pull request
Jan 29, 2021
After solidusio/solidus#3641 it's requested to create and perform refunds in two different operations. This commit aligns the code to the new standard. Co-authored-by: Rainer Dema <rainerdema@users.noreply.github.com>
kennyadsl
added a commit
to solidusio/solidus_stripe
that referenced
this pull request
Jan 29, 2021
After solidusio/solidus#3641 it's requested to create and perform refunds in two different operations. This commit aligns the code to the new standard. Co-authored-by: Rainer Dema <rainerdema@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
changelog:solidus_core
Changes to the solidus_core gem
type:enhancement
Proposed or newly added feature
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR allows creating Refunds without
perform!
being automatically called by a Rails callback.This is a combination of two leftover PRs that we want to bring into Solidus
v2.11
:Spree::Refund#perform!
callback #3181 Introduce deprecation warning when usingSpree::Refund#perform!
callback by @aitbwThey were both incomplete: the first one was doing the job but without taking care of adding a deprecation warning, the second one was only adding the deprecation warning without actually change the behavior. If this is an accepted approach we can close both of them.
I merged them together and added some missing pieces. In 3.0 we'll introduce a deprecation warning for that attribute so that people can remove that since it will be useless.
Some notes for the CHANGELOG entry:
Checklist:
[ ] I have attached screenshots to this PR for visual changes (if needed)