Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spree::Variant could not be consistent #3036

Closed
kennyadsl opened this issue Jan 14, 2019 · 0 comments · Fixed by #3043
Closed

Spree::Variant could not be consistent #3036

kennyadsl opened this issue Jan 14, 2019 · 0 comments · Fixed by #3043
Labels
type:bug Error, flaw or fault

Comments

@kennyadsl
Copy link
Member

Describe the bug

Right now we can have a Spree::Variant instance that is not consistent since the price cannot be created without a product associated with the variant.

When [set_price]
(

before_validation :set_price
) is called before validation it raises an error if the product is not set.

Solidus Version:

master

To Reproduce

Steps to reproduce the behavior:

  1. Open a rails console on a sandbox generated on master
  2. Run:
v = Spree::Variant.new
=> #<Spree::Variant id: nil, sku: "", weight: 0.0, height: nil, width: nil, depth: nil, deleted_at: nil, is_master: false, product_id: nil, cost_price: nil, position: nil, cost_currency: nil, track_inventory: true, tax_category_id: nil, updated_at: nil, created_at: nil>
irb(main):090:0> v.valid?
Traceback (most recent call last):
        1: from (irb):90
RuntimeError (No master variant found to infer price)

Expected behavior

It should not raise an exception and an error should be added to the object instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Error, flaw or fault
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant