Skip to content

Conversation

@mamhoff
Copy link
Contributor

@mamhoff mamhoff commented Oct 31, 2025

Summary

This stops the Percent promotion calculator from overriding Spree::Calculator#compute and make sure the PercentWithCap calculator only responds to #compute_line_item.

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.

Adds YARD docs to the probably most important calculator in the
promotion system. Also stops it from overriding "compute" such that
behavior from `Spree::Calculator` is inherited.

Furthermore, improves the specs so that the polymorphism is tested.
We want `compute` to stay intact, and we want the calculator to document
what kind of items it can discount.

That's why we need to stop inheriting from the `Percent` calculator,
because that will work with shipments and shipping rates, while anything
to do with Distributed Amounts only works on line items.
@mamhoff mamhoff requested a review from a team as a code owner October 31, 2025 15:44
@github-actions github-actions bot added the changelog:solidus_promotions Changes to the solidus_promotions gem label Oct 31, 2025
@codecov
Copy link

codecov bot commented Oct 31, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.34%. Comparing base (2d1fcff) to head (6b2f3df).
⚠️ Report is 17 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6352   +/-   ##
=======================================
  Coverage   89.34%   89.34%           
=======================================
  Files         961      961           
  Lines       20165    20170    +5     
=======================================
+ Hits        18016    18021    +5     
  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 changed the title Fix percent calculcator dispatch Fix percent calculator dispatch Oct 31, 2025
@tvdeyen tvdeyen added this to the 4.7 milestone Nov 1, 2025
@mamhoff mamhoff merged commit 643d2ff into solidusio:main Nov 1, 2025
39 checks passed
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

Development

Successfully merging this pull request may close these issues.

3 participants