Skip to content

Stop passing line_item to compute unit cancelation adjustment's amount#5278

Closed
BenMorganIO wants to merge 1 commit intosolidusio:mainfrom
BenMorganIO:unit-cancel-improvements
Closed

Stop passing line_item to compute unit cancelation adjustment's amount#5278
BenMorganIO wants to merge 1 commit intosolidusio:mainfrom
BenMorganIO:unit-cancel-improvements

Conversation

@BenMorganIO
Copy link
Contributor

Summary

Simple refactoring for the Spree::UnitCancel. There's no need to do inventory_unit.line_item and then pass the line item through everywhere when we can get it through a has_one. I also changed weighted_amount to accept an arbitrary amount instead of a line item object.

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.

@BenMorganIO BenMorganIO requested a review from a team as a code owner July 23, 2023 16:52
@github-actions github-actions bot added the changelog:solidus_core Changes to the solidus_core gem label Jul 23, 2023
@BenMorganIO BenMorganIO force-pushed the unit-cancel-improvements branch from 89d91bd to 0e5582f Compare July 23, 2023 16:58
raise "Adjustable does not match line item" unless line_item == inventory_unit.line_item

-weighted_line_item_amount(line_item)
def compute_amount
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compute_amount is a public method. We have two ways of handling the change of the signature of a public method:

  1. Rename the method and deprecate compute_amount, delegating its usage to the new method.
  2. Keep compute_amount with the same signature but make the argument optional and deprecate its usage.

I think it works both ways, up to you!

@kennyadsl kennyadsl changed the title no need to pass line_item when a has_one will doin Spree::UnitCancel Stop passing line_item to compute unit cancelation adjustment's amount Jul 25, 2023
@adammathys
Copy link
Member

Closing because there haven't been any updates in 2 years.

Please re-open with the requested changes if you'd still like to have this merged! ❤️

@adammathys adammathys closed this Jul 31, 2025
@codecov
Copy link

codecov bot commented Jul 31, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.27%. Comparing base (568f4ed) to head (0e5582f).
⚠️ Report is 2633 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5278      +/-   ##
==========================================
+ Coverage   88.71%   93.27%   +4.56%     
==========================================
  Files         563      123     -440     
  Lines       13890     3287   -10603     
==========================================
- Hits        12322     3066    -9256     
+ Misses       1568      221    -1347     

☔ 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.

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.

3 participants