-
-
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
Do not consider promotions without actions as active #3749
Do not consider promotions without actions as active #3749
Conversation
Thanks for hopping on this @DanielePalombo ! Apologies, I've been underwater with work and haven't been able to make time back to this. |
96bd049
to
473870c
Compare
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.
Left a non-blocking comment. 👍
Thanks to both @wildbillcat and @DanielePalombo.
core/app/models/spree/promotion.rb
Outdated
@@ -84,7 +93,7 @@ def not_expired? | |||
end | |||
|
|||
def active? | |||
started? && not_expired? | |||
started? && not_expired? && (Spree::Config.actionless_promotion_inactive ? actions.present? : 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.
What about a different method (has_actions?
) for this?
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.
I think that has_actions?
would be confused because it will return true
is the preference actionless_promotion_inactive
is false.
I have considered this suggestion and following the @aldesantis comments I have named it consider_active_by_actions_presence
core/lib/generators/solidus/install/templates/config/initializers/spree.rb.tt
Outdated
Show resolved
Hide resolved
…no actions are assigned
e69ab26
to
a9b49c4
Compare
a9b49c4
to
08e1ba7
Compare
08e1ba7
to
84192cf
Compare
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.
Left a couple of comments about some terms. The rest looks good to me, thanks!
core/lib/generators/solidus/install/templates/config/initializers/spree.rb.tt
Outdated
Show resolved
Hide resolved
Remove the join table otherwise started_and_unexpired scope will return only the promotion with actions, and the code doesn't reproduce the deprecated behavior
84192cf
to
109c1bb
Compare
@aldesantis can you please review again when you have some time? 🙏 |
This PR is based on #3596.
From original PR:
This is a proposed solution to #2777 where action-less promotions were considered active. As opposed to my original thought of implementing validation, given that there is no state toggle on the promotion that it would make sense to embrace the inferred state. So this implementation just causes a promotion to be considered inactive until it has actions, in addition to the other required material. Otherwise it is considered inactive.
In the process I found the coupon promotion handler already treated action-less coupons as inactive, so I updated it to continue this behavior.
I have only added the spec and refactored it.
Thank you @wildbillcat
Checklist: