Promotions: Fix eligibility calculation in dry runs#6429
Open
mamhoff wants to merge 1 commit intosolidusio:mainfrom
Open
Promotions: Fix eligibility calculation in dry runs#6429mamhoff wants to merge 1 commit intosolidusio:mainfrom
mamhoff wants to merge 1 commit intosolidusio:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6429 +/- ##
=======================================
Coverage 89.59% 89.59%
=======================================
Files 984 984
Lines 20651 20651
=======================================
Hits 18502 18502
Misses 2149 2149 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
tvdeyen
approved these changes
Mar 24, 2026
f2499b3 to
3e9f755
Compare
Commit 4b99e1e introduced a subtle bug when the `dry_run` parameter was true: Because `filter_map` filters out `false` from arrays, every benefit would now be eligible! This changes the loop to distinguish between `nil` (for non-applicable conditions) and `false` for (for applicable conditions). It also adds specs for this - very central - method to the promotions system.
3e9f755 to
bcd2b28
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Commit 4b99e1e introduced a subtle bug when the
dry_runparameter was true: Becausefilter_mapfilters outfalsefrom arrays, every benefit would now be eligible!This changes the loop to distinguish between
nil(for non-applicable conditions) andfalsefor (for applicable conditions).It also adds specs for this - very central - method to the promotions system.
This makes the dry run not return errors for line-item level conditions if there are order-level conditions present. We probably need a DryRunDiscountOrder object to catch this, with the current architecture, it's not feasible.
Checklist
Check out our PR guidelines for more details.
The following are mandatory for all PRs:
The following are not always needed: