Skip to content

Promotions: Fix eligibility calculation in dry runs#6429

Open
mamhoff wants to merge 1 commit intosolidusio:mainfrom
mamhoff:fix-eligible-by-applicable-conditions
Open

Promotions: Fix eligibility calculation in dry runs#6429
mamhoff wants to merge 1 commit intosolidusio:mainfrom
mamhoff:fix-eligible-by-applicable-conditions

Conversation

@mamhoff
Copy link
Contributor

@mamhoff mamhoff commented Mar 24, 2026

Summary

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.

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:

  • 📖 I have updated the README to account for my changes.
  • 📑 I have documented new code with YARD.
  • 🛣️ I have opened a PR to update the guides.
  • ✅ I have added automated tests to cover my changes.
  • 📸 I have attached screenshots to demo visual changes.

@mamhoff mamhoff requested a review from a team as a code owner March 24, 2026 15:52
@mamhoff mamhoff changed the title Promotions: Fix eligibility calculation if dry_run true Promotions: Fix eligibility calculation in dry runs Mar 24, 2026
@github-actions github-actions bot added the changelog:solidus_promotions Changes to the solidus_promotions gem label Mar 24, 2026
@codecov
Copy link

codecov bot commented Mar 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.59%. Comparing base (96c0357) to head (bcd2b28).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mamhoff mamhoff force-pushed the fix-eligible-by-applicable-conditions branch 2 times, most recently from f2499b3 to 3e9f755 Compare March 24, 2026 17:13
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.
@mamhoff mamhoff force-pushed the fix-eligible-by-applicable-conditions branch from 3e9f755 to bcd2b28 Compare March 24, 2026 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:solidus_promotions Changes to the solidus_promotions gem

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants