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

Do not consider promotions without actions as active #3749

Merged

Conversation

DanielePalombo
Copy link
Contributor

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:

  • I have followed Pull Request guidelines
  • I have added a detailed description into each commit message
  • I have updated Guides and README accordingly to this change (if needed)
  • I have added tests to cover this change (if needed)
  • I have attached screenshots to this PR for visual changes (if needed)

@wildbillcat
Copy link
Contributor

Thanks for hopping on this @DanielePalombo ! Apologies, I've been underwater with work and haven't been able to make time back to this.

@DanielePalombo DanielePalombo force-pushed the 2777-inactive-actionless-promotions branch 2 times, most recently from 96bd049 to 473870c Compare September 4, 2020 09:25
Copy link
Member

@kennyadsl kennyadsl left a 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.

@@ -84,7 +93,7 @@ def not_expired?
end

def active?
started? && not_expired?
started? && not_expired? && (Spree::Config.actionless_promotion_inactive ? actions.present? : true)
Copy link
Member

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?

Copy link
Contributor Author

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

@DanielePalombo DanielePalombo marked this pull request as ready for review September 7, 2020 10:48
@kennyadsl kennyadsl added Needs Core Team Review changelog:solidus_core Changes to the solidus_core gem labels Sep 8, 2020
@kennyadsl kennyadsl changed the title 2777 inactive actionless promotions Do not consider promotions without actions as active Sep 8, 2020
@kennyadsl kennyadsl added this to the 2.11 milestone Sep 9, 2020
@DanielePalombo DanielePalombo force-pushed the 2777-inactive-actionless-promotions branch 2 times, most recently from e69ab26 to a9b49c4 Compare October 2, 2020 07:58
@DanielePalombo DanielePalombo force-pushed the 2777-inactive-actionless-promotions branch from a9b49c4 to 08e1ba7 Compare October 2, 2020 09:24
@DanielePalombo DanielePalombo force-pushed the 2777-inactive-actionless-promotions branch from 08e1ba7 to 84192cf Compare October 2, 2020 12:04
Copy link
Member

@kennyadsl kennyadsl left a 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/spree/core/engine.rb Outdated Show resolved Hide resolved
core/lib/spree/app_configuration.rb 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
@DanielePalombo DanielePalombo force-pushed the 2777-inactive-actionless-promotions branch from 84192cf to 109c1bb Compare October 2, 2020 12:50
@kennyadsl
Copy link
Member

@aldesantis can you please review again when you have some time? 🙏

@kennyadsl kennyadsl requested a review from a team October 7, 2020 10:49
@kennyadsl kennyadsl merged commit 176e3a7 into solidusio:master Oct 7, 2020
@DanielePalombo DanielePalombo deleted the 2777-inactive-actionless-promotions branch October 7, 2020 11:53
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants