Skip to content

WIP: Introduce new middleware stock coordinator#6484

Draft
sofiabesenski4 wants to merge 11 commits into
solidusio:mainfrom
SuperGoodSoft:introduce-new-middleware-stock-coordinator
Draft

WIP: Introduce new middleware stock coordinator#6484
sofiabesenski4 wants to merge 11 commits into
solidusio:mainfrom
SuperGoodSoft:introduce-new-middleware-stock-coordinator

Conversation

@sofiabesenski4
Copy link
Copy Markdown
Contributor

@sofiabesenski4 sofiabesenski4 commented May 14, 2026

WIP

This refactoring of the existing SimpleCoordinator leaves it in a state that retains the original functionality, and higher level shape, but encapsulates the lower level logic into middleware components.

Next steps will be to reconsider how the middleware components are encapsulated, setting up the middleware orchestration, and adding unit specs to prevent regressions.

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.

We want to support additional keyword arguments to this class and a
positional argument interferes with this.

Co-authored-by: Jared Norman <jared@super.gd>
Co-authored-by: Adam Mueller <adam@super.gd>
Co-authored-by: Noah Silvera <noah@super.gd>
@github-actions github-actions Bot added the changelog:solidus_core Changes to the solidus_core gem label May 14, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 14, 2026

Codecov Report

❌ Patch coverage is 98.07692% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.72%. Comparing base (a0746e6) to head (ca9ae0d).

Files with missing lines Patch % Lines
core/app/models/spree/stock/simple_coordinator.rb 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6484      +/-   ##
==========================================
+ Coverage   89.68%   89.72%   +0.03%     
==========================================
  Files         991     1000       +9     
  Lines       20832    20932     +100     
==========================================
+ Hits        18683    18781      +98     
- Misses       2149     2151       +2     

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

Co-authored-by: Noah Silvera <noah@super.gd>
Co-authored-by: Adam Mueller <adam@super.gd>
@sofiabesenski4 sofiabesenski4 force-pushed the introduce-new-middleware-stock-coordinator branch from 6b44d32 to 4a86af5 Compare May 14, 2026 20:34
sofiabesenski4 and others added 9 commits May 14, 2026 13:37
Co-authored-by: Noah Silvera <noah@super.gd>
Co-authored-by: Adam Mueller <adam@super.gd>
This starts the pattern of delegating low level operations to middleware
objects.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sofiabesenski4 sofiabesenski4 force-pushed the introduce-new-middleware-stock-coordinator branch from 4a86af5 to ca9ae0d Compare May 14, 2026 20:38
Comment on lines +6 to +9
context[:availability] = Spree::Stock::Availability.new(
variants: context[:desired].variants,
stock_locations: context[:stock_locations]
)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is definitely an example of how overusing this approach makes the code worse. This has seriously obfuscated the dependency chain of the availability and desired variants objects. If we have some dependent computed stuff like this, maybe we just make this methods on the context object or something? It's worth considering this further.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed! I didn't put too much thought into how things shook out entirely at this point in the draft. Will definitely revisit before opening for review.

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.

2 participants