Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Fix Meilisearch price-filter spec to drop the placeholder default variant
Łukasz Adamczyk14e2d31ed7df
diff --git a/spree/api/spec/controllers/spree/api/v3/store/products/meilisearch_integration_spec.rb b/spree/api/spec/controllers/spree/api/v3/store/products/meilisearch_integration_spec.rbindex acf828ba61..0a7f9c47cc 100644--- a/spree/api/spec/controllers/spree/api/v3/store/products/meilisearch_integration_spec.rb+++ b/spree/api/spec/controllers/spree/api/v3/store/products/meilisearch_integration_spec.rb@@ -31,6 +31,16 @@ RSpec.describe 'Meilisearch Integration', type: :controller, if: ENV['MEILISEARClet(:small) { create(:option_value, option_type: size_option, name: 'small', presentation: 'S') }let(:large) { create(:option_value, option_type: size_option, name: 'large', presentation: 'L') }+ # create(:product) seeds an option-less placeholder default variant priced by+ # the factory. Once real option variants exist that placeholder is meaningless+ # (import/admin flows delete it), so drop it and re-point the default — otherwise+ # the product's price resolves to the placeholder's factory price, not the variant's.+ def make_default_variant(product, variant)+ product.update!(default_variant_id: variant.id)+ product.variants.where.missing(:option_value_variants).destroy_all+ product.reload+ end+# Products with different attributeslet!(:cheap_red_shirt) dop = create(:product, name: 'Red Cotton Shirt', status: 'active', store: store, taxons: [clothing_category])@@ -38,6 +48,7 @@ RSpec.describe 'Meilisearch Integration', type: :controller, if: ENV['MEILISEARCp.option_types << size_optionv = create(:variant, product: p, option_values: [red, small])v.prices.find_or_create_by!(currency: 'USD').update!(amount: 19.99)+ make_default_variant(p, v)pend@@ -46,6 +57,7 @@ RSpec.describe 'Meilisearch Integration', type: :controller, if: ENV['MEILISEARCp.option_types << color_optionv = create(:variant, product: p, option_values: [blue, large])v.prices.find_or_create_by!(currency: 'USD').update!(amount: 89.99)+ make_default_variant(p, v)pend@@ -55,6 +67,7 @@ RSpec.describe 'Meilisearch Integration', type: :controller, if: ENV['MEILISEARCp.option_types << size_optionv = create(:variant, product: p, option_values: [blue, small])v.prices.find_or_create_by!(currency: 'USD').update!(amount: 129.99)+ make_default_variant(p, v)pend