Skip to content

Handle missing master price when adding a variant#6506

Open
minhluuquang wants to merge 1 commit into
solidusio:mainfrom
minhluuquang:fix-4831-variant-without-master-price
Open

Handle missing master price when adding a variant#6506
minhluuquang wants to merge 1 commit into
solidusio:mainfrom
minhluuquang:fix-4831-variant-without-master-price

Conversation

@minhluuquang

Copy link
Copy Markdown
Contributor

Summary

Fixes #4831.

This prevents the admin variant form from raising when a product's master variant has no default price. The new variant action still copies the master default price when it exists, but skips that clone when it is missing so the rendered form can build a blank default-currency price field.

Testing

  • bundle exec rspec spec/controllers/spree/admin/variants_controller_spec.rb
  • bundle exec standardrb backend/app/controllers/spree/admin/variants_controller.rb backend/spec/controllers/spree/admin/variants_controller_spec.rb

I ran these in the backend gem context with Ruby 4.0.1 via mise. Full bin/build was not run locally.

@minhluuquang minhluuquang requested a review from a team as a code owner June 29, 2026 08:59
@github-actions github-actions Bot added the changelog:solidus_backend Changes to the solidus_backend gem label Jun 29, 2026
stub_authorization!

describe "#new" do
render_views

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.

Is this necessary?

@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.47%. Comparing base (8d781ac) to head (5ccf596).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6506      +/-   ##
==========================================
- Coverage   89.68%   89.47%   -0.22%     
==========================================
  Files         993      922      -71     
  Lines       20863    19048    -1815     
==========================================
- Hits        18712    17044    -1668     
+ Misses       2151     2004     -147     

☔ View full report in Codecov by Harness.
📢 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_backend Changes to the solidus_backend gem

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exception when adding a variant for a product with no master price

2 participants