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
Migrate v3 API off the master variant
Łukasz Adamczyk5a56bdc6c805
diff --git a/spree/api/app/controllers/spree/api/v3/admin/media_controller.rb b/spree/api/app/controllers/spree/api/v3/admin/media_controller.rbindex 7c8d5090fb..81fb69484b 100644--- a/spree/api/app/controllers/spree/api/v3/admin/media_controller.rb+++ b/spree/api/app/controllers/spree/api/v3/admin/media_controller.rb@@ -37,7 +37,7 @@ module Spreeauthorize!(:update, @product)@parent = if params[:variant_id].present?- @product.variants_including_master.find_by_prefix_id!(params[:variant_id])+ @product.variants.find_by_prefix_id!(params[:variant_id])else@productend@@ -51,8 +51,9 @@ module Spreeend# For product-scoped listings we surface BOTH product-level assets and any- # legacy master-pinned assets, so existing data keeps showing up while- # merchants migrate. New uploads land on `Spree::Product` (see #set_parent).+ # legacy assets still pinned to the default variant, so existing data keeps+ # showing up while merchants migrate. New uploads land on `Spree::Product`+ # (see #set_parent).def scopereturn super if params[:variant_id].present?@@ -60,7 +61,7 @@ module Spreeviewable_type: 'Spree::Product', viewable_id: @product.id).or(Spree::Asset.where(- viewable_type: 'Spree::Variant', viewable_id: @product.master&.id+ viewable_type: 'Spree::Variant', viewable_id: @product.default_variant&.id)).order(:position)enddiff --git a/spree/api/app/controllers/spree/api/v3/admin/products/variants_controller.rb b/spree/api/app/controllers/spree/api/v3/admin/products/variants_controller.rbindex 6400478465..c34e54af89 100644--- a/spree/api/app/controllers/spree/api/v3/admin/products/variants_controller.rb+++ b/spree/api/app/controllers/spree/api/v3/admin/products/variants_controller.rb@@ -22,7 +22,7 @@ module Spreeenddef parent_association- :variants_including_master+ :variantsenddef scope_includesdiff --git a/spree/api/app/controllers/spree/api/v3/admin/products_controller.rb b/spree/api/app/controllers/spree/api/v3/admin/products_controller.rbindex 32687d1e6e..d3330d57dc 100644--- a/spree/api/app/controllers/spree/api/v3/admin/products_controller.rb+++ b/spree/api/app/controllers/spree/api/v3/admin/products_controller.rb@@ -116,7 +116,7 @@ module Spree:tax_category,product_publications: :channel,primary_media: [attachment_attachment: :blob],- master: [:prices, stock_items: [:stock_location, :active_stock_reservations]],+ default_variant: [:prices, stock_items: [:stock_location, :active_stock_reservations]],variants: [:prices, stock_items: [:stock_location, :active_stock_reservations]]]end@@ -157,9 +157,9 @@ module Spree# docs/plans/6.0-remove-master-variant.md.## Top-level `prices` is a convenience for simple (no-options)- # products: the merchant doesn't need to know the master variant- # exists, so they ship prices alongside name/status and the- # `Spree::Product#prices=` setter forwards them to the master.+ # products: the merchant doesn't need to know about the default+ # variant, so they ship prices alongside name/status and the+ # `Spree::Product#prices=` setter forwards them to it.params.permit(:name, :description, :slug, :status,:meta_title, :meta_description, :meta_keywords,diff --git a/spree/api/app/controllers/spree/api/v3/store/products_controller.rb b/spree/api/app/controllers/spree/api/v3/store/products_controller.rbindex 7da57dc165..0b3295910a 100644--- a/spree/api/app/controllers/spree/api/v3/store/products_controller.rb+++ b/spree/api/app/controllers/spree/api/v3/store/products_controller.rb@@ -37,7 +37,7 @@ module Spree[product_publications: [],primary_media: [attachment_attachment: :blob],- master: [:prices, stock_items: [:stock_location, :active_stock_reservations]],+ default_variant: [:prices, stock_items: [:stock_location, :active_stock_reservations]],variants: [:prices, stock_items: [:stock_location, :active_stock_reservations]]]enddiff --git a/spree/api/spec/controllers/spree/api/v3/admin/price_lists_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/admin/price_lists_controller_spec.rbindex 2b416986d5..fbeaf8f61e 100644--- a/spree/api/spec/controllers/spree/api/v3/admin/price_lists_controller_spec.rb+++ b/spree/api/spec/controllers/spree/api/v3/admin/price_lists_controller_spec.rb@@ -53,7 +53,7 @@ RSpec.describe Spree::Api::V3::Admin::PriceListsController, type: :controller do# prices. Variants in `prices` implicitly become part of the list# via the unique-key upsert — no separate `product_ids` round trip.let(:product) { create(:product) }- let(:variant_a) { product.master }+ let(:variant_a) { product.default_variant }let(:variant_b) { create(:variant, product: product) }it 'persists metadata, rules, and prices in one request' do@@ -96,7 +96,7 @@ RSpec.describe Spree::Api::V3::Admin::PriceListsController, type: :controller docontext 'cross-store IDOR — membership in another store' dolet(:other_store) { create(:store) }let(:foreign_product) { create(:product, store: other_store) }- let(:foreign_variant) { foreign_product.master }+ let(:foreign_variant) { foreign_product.default_variant }it 'ignores another store\'s product in product_ids' dopost :create,@@ -383,7 +383,7 @@ RSpec.describe Spree::Api::V3::Admin::PriceListsController, type: :controller dodescribe 'PATCH #update — prices nullability contract' dolet(:product) { create(:product) }- let(:variant) { product.master }+ let(:variant) { product.default_variant }# Seed an existing override so we can prove it survives or gets# cleared depending on the request shape.let!(:price) dodiff --git a/spree/api/spec/controllers/spree/api/v3/admin/prices_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/admin/prices_controller_spec.rbindex 7bd6a348cc..caf6d29432 100644--- a/spree/api/spec/controllers/spree/api/v3/admin/prices_controller_spec.rb+++ b/spree/api/spec/controllers/spree/api/v3/admin/prices_controller_spec.rb@@ -7,12 +7,12 @@ RSpec.describe Spree::Api::V3::Admin::PricesController, type: :controller dolet(:price_list) { create(:price_list, store: store) }let(:product) { create(:product) }- let(:variant) { product.master }+ let(:variant) { product.default_variant }before { request.headers.merge!(headers) }describe 'GET #index' do- # The product factory seeds a USD base price on `master` for the+ # The product factory seeds a USD base price on the default variant for the# store's default currency, so we reuse it instead of inserting one# (the unique index on `(variant_id, currency, price_list_id)` blocks# duplicates).@@ -38,7 +38,7 @@ RSpec.describe Spree::Api::V3::Admin::PricesController, type: :controller doit 'filters by currency via Ransack' do# A second currency on a different variant — same variant + EUR- # would conflict with the factory-seeded USD master price if Spree+ # would conflict with the factory-seeded USD default-variant price if Spree# auto-mirrored currencies, but it doesn't.eur_variant = create(:variant, product: product)eur_price = create(:price, variant: eur_variant, currency: 'EUR', amount: 9.0)@@ -58,7 +58,7 @@ RSpec.describe Spree::Api::V3::Admin::PricesController, type: :controller do# invariant across both databases.it 'sorts by variant product name without raising' doother_product = create(:product, name: 'AAA')- other_price = other_product.master.prices.find_by!(currency: 'USD', price_list_id: nil)+ other_price = other_product.default_variant.prices.find_by!(currency: 'USD', price_list_id: nil)get :index, params: { sort: 'variant_product_name,variant_id' }, as: :json@@ -69,7 +69,7 @@ RSpec.describe Spree::Api::V3::Admin::PricesController, type: :controller doit 'scopes to a single product via q[variant_product_id_eq] (base prices only)' doother_product = create(:product)- other_base = other_product.master.prices.find_by!(currency: 'USD', price_list_id: nil)+ other_base = other_product.default_variant.prices.find_by!(currency: 'USD', price_list_id: nil)get :index,params: {@@ -132,7 +132,7 @@ RSpec.describe Spree::Api::V3::Admin::PricesController, type: :controller doit 'excludes prices from other stores' doother_store = create(:store)other_product = create(:product, store: other_store)- other_price = other_product.master.prices.find_by!(currency: 'USD', price_list_id: nil)+ other_price = other_product.default_variant.prices.find_by!(currency: 'USD', price_list_id: nil)get :index, as: :json@@ -280,10 +280,10 @@ RSpec.describe Spree::Api::V3::Admin::PricesController, type: :controller docontext 'cross-store IDOR — a variant in another store' dolet(:other_store) { create(:store) }let(:other_product) { create(:product, store: other_store) }- let(:other_variant) { other_product.master }+ let(:other_variant) { other_product.default_variant }it 'rejects writing a price on another store\'s variant and leaves it untouched' do- # The factory seeds a USD base price on the foreign master; capture it+ # The factory seeds a USD base price on the foreign default variant; capture it# so we prove an in-place update didn't slip through (count alone wouldn't).foreign_price = other_variant.prices.find_by!(currency: 'USD', price_list_id: nil)@@ -338,7 +338,7 @@ RSpec.describe Spree::Api::V3::Admin::PricesController, type: :controller docontext 'cross-store IDOR' dolet(:other_store) { create(:store) }- let(:other_variant) { create(:product, store: other_store).master }+ let(:other_variant) { create(:product, store: other_store).default_variant }it "404s when writing a price on another store's variant" doexpect do@@ -376,7 +376,7 @@ RSpec.describe Spree::Api::V3::Admin::PricesController, type: :controller doendit "404s when rebinding a price to another store's variant" do- other_variant = create(:product, store: create(:store)).master+ other_variant = create(:product, store: create(:store)).default_variantpatch :update, params: {id: base_price.prefixed_id, variant_id: other_variant.prefixed_iddiff --git a/spree/api/spec/controllers/spree/api/v3/admin/products/media_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/admin/products/media_controller_spec.rbindex 6a1a12e6b4..37f6b4a4a7 100644--- a/spree/api/spec/controllers/spree/api/v3/admin/products/media_controller_spec.rb+++ b/spree/api/spec/controllers/spree/api/v3/admin/products/media_controller_spec.rb@@ -144,14 +144,14 @@ RSpec.describe Spree::Api::V3::Admin::MediaController, type: :controller doendend- context 'with legacy master-pinned assets' do- let!(:legacy_master_image) { create(:image, viewable: product.master) }+ context 'with legacy default-variant-pinned assets' do+ let!(:legacy_variant_image) { create(:image, viewable: product.default_variant) }it 'still surfaces legacy assets in the listing' doget :index, params: { product_id: product.prefixed_id }, as: :jsonids = json_response['data'].map { |a| a['id'] }- expect(ids).to include(legacy_master_image.prefixed_id)+ expect(ids).to include(legacy_variant_image.prefixed_id)endendenddiff --git a/spree/api/spec/controllers/spree/api/v3/admin/products_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/admin/products_controller_spec.rbindex 86f89f8b48..5674f235a8 100644--- a/spree/api/spec/controllers/spree/api/v3/admin/products_controller_spec.rb+++ b/spree/api/spec/controllers/spree/api/v3/admin/products_controller_spec.rb@@ -119,8 +119,8 @@ RSpec.describe Spree::Api::V3::Admin::ProductsController, type: :controller doexpect(ids).not_to include(non_matching_product.prefixed_id)end- it 'matches by master variant SKU' do- matching_product.master.update!(sku: 'ESPRESSO-PRO-2026')+ it 'matches by default variant SKU' do+ matching_product.default_variant.update!(sku: 'ESPRESSO-PRO-2026')get :index, params: { q: { search: 'ESPRESSO-PRO' } }, as: :json@@ -158,13 +158,13 @@ RSpec.describe Spree::Api::V3::Admin::ProductsController, type: :controller docontext 'by price' dolet!(:cheap_product) docreate(:product, name: 'Cheap').tap do |p|- p.master.prices.first.update!(amount: 10.0)+ p.default_variant.prices.first.update!(amount: 10.0)endendlet!(:expensive_product) docreate(:product, name: 'Expensive').tap do |p|- p.master.prices.first.update!(amount: 100.0)+ p.default_variant.prices.first.update!(amount: 100.0)endend@@ -318,7 +318,7 @@ RSpec.describe Spree::Api::V3::Admin::ProductsController, type: :controller doexpect {post :create, params: product_params, as: :json}.to change(Spree::Product, :count).by(1)- .and change(Spree::Variant, :count).by(4) # master (auto-created until 6.0 master removal) + 3 variants+ .and change(Spree::Variant, :count).by(3) # 3 option variantsexpect(response).to have_http_status(:created)@@ -334,7 +334,7 @@ RSpec.describe Spree::Api::V3::Admin::ProductsController, type: :controller doexpect(created.tag_list).to match_array(['premium', 'cotton', 'summer'])expect(created.taxons).to match_array([category1, category2])- # Cost price now lives on the variant, not the master delegate.+ # Cost price now lives on the variant, not delegated from the product.small_variant = created.variants.find_by(sku: 'PREM-TEE-S')expect(small_variant.cost_price.to_f).to eq(8.50)@@ -494,7 +494,7 @@ RSpec.describe Spree::Api::V3::Admin::ProductsController, type: :controller do# Mirrors the exact wire shape the dashboard ships from# `new.tsx` for a simple product with media + inventory:# - status, channels, custom_fields, media, variants[] with empty- # options + stock_items routed to the master via apply_variants.+ # options + stock_items routed to the default variant via apply_variants.blob1 = ActiveStorage::Blob.create_and_upload!(io: File.open(Spree::Core::Engine.root.join('spec', 'fixtures', 'thinking-cat.jpg')),filename: 'one.jpg',@@ -530,9 +530,9 @@ RSpec.describe Spree::Api::V3::Admin::ProductsController, type: :controller doexpect(response).to have_http_status(:created)created = Spree::Product.find_by(name: 'test product')expect(created.media.count).to eq(2)- expect(created.master.stock_items.find_by(stock_location: location).count_on_hand).to eq(10)- # No phantom non-master variant.- expect(created.variants.count).to eq(0)+ expect(created.default_variant.stock_items.find_by(stock_location: location).count_on_hand).to eq(10)+ # Simple product has exactly one variant — the default variant.+ expect(created.variants.count).to eq(1)endit 'returns 422 with field-level details for an unknown custom_field_definition_id' do@@ -552,7 +552,7 @@ RSpec.describe Spree::Api::V3::Admin::ProductsController, type: :controller doendcontext 'with top-level prices (simple-product flow)' do- it 'forwards prices to the auto-created master variant' do+ it 'forwards prices to the auto-created default variant' dopost :create, params: {name: 'Simple Product',prices: [@@ -563,8 +563,8 @@ RSpec.describe Spree::Api::V3::Admin::ProductsController, type: :controller doexpect(response).to have_http_status(:created)created = Spree::Product.find_by(name: 'Simple Product')- usd = created.master.prices.find_by(currency: 'USD')- eur = created.master.prices.find_by(currency: 'EUR')+ usd = created.default_variant.prices.find_by(currency: 'USD')+ eur = created.default_variant.prices.find_by(currency: 'EUR')expect(usd.amount).to eq(12.50)expect(eur.amount).to eq(11.00)expect(eur.compare_at_amount).to eq(13.99)@@ -586,7 +586,7 @@ RSpec.describe Spree::Api::V3::Admin::ProductsController, type: :controller do}, as: :jsonexpect(response).to have_http_status(:created)- price = Spree::Product.find_by(name: 'String Price Product').master.prices.find_by(currency: 'USD')+ price = Spree::Product.find_by(name: 'String Price Product').default_variant.prices.find_by(currency: 'USD')expect(price.amount).to eq(29.99)expect(price.compare_at_amount).to eq(39.99)end@@ -658,7 +658,7 @@ RSpec.describe Spree::Api::V3::Admin::ProductsController, type: :controller docontext 'with full payload: name, description, status, categories, tags, SEO, variants with multi-currency prices' dolet!(:product_to_update) docreate(:product_with_option_types).tap do |p|- p.master.update!(sku: 'OLD-SKU')+ p.default_variant.update!(sku: 'OLD-SKU')endenddiff --git a/spree/api/spec/controllers/spree/api/v3/admin/stock_transfers_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/admin/stock_transfers_controller_spec.rbindex 5577a0d96f..713703b49f 100644--- a/spree/api/spec/controllers/spree/api/v3/admin/stock_transfers_controller_spec.rb+++ b/spree/api/spec/controllers/spree/api/v3/admin/stock_transfers_controller_spec.rb@@ -67,7 +67,7 @@ RSpec.describe Spree::Api::V3::Admin::StockTransfersController, type: :controlleendit "drops variants belonging to another store and surfaces invalid_variants" do- foreign_variant = create(:product, store: create(:store)).master+ foreign_variant = create(:product, store: create(:store)).default_variantexpect dopost :create, params: base_params.merge(diff --git a/spree/api/spec/controllers/spree/api/v3/admin/variants_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/admin/variants_controller_spec.rbindex 0888957a3d..37c86f6297 100644--- a/spree/api/spec/controllers/spree/api/v3/admin/variants_controller_spec.rb+++ b/spree/api/spec/controllers/spree/api/v3/admin/variants_controller_spec.rb@@ -20,11 +20,10 @@ RSpec.describe Spree::Api::V3::Admin::VariantsController, type: :controller doexpect(json_response['data'].map { |v| v['id'] }).to include(variant.prefixed_id)end- it 'excludes master variants' do+ it 'includes the default variant' dosubject- master_ids = product.master.prefixed_idreturned_ids = json_response['data'].map { |v| v['id'] }- expect(returned_ids).not_to include(master_ids)+ expect(returned_ids).to include(product.default_variant.prefixed_id)endit 'returns pagination metadata' dodiff --git a/spree/api/spec/controllers/spree/api/v3/store/products_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/store/products_controller_spec.rbindex 111702d3eb..1b70d88555 100644--- a/spree/api/spec/controllers/spree/api/v3/store/products_controller_spec.rb+++ b/spree/api/spec/controllers/spree/api/v3/store/products_controller_spec.rb@@ -74,8 +74,8 @@ RSpec.describe Spree::Api::V3::Store::ProductsController, type: :controller docontext 'currency scoping' dolet!(:eur_only_product) docreate(:product, status: 'active').tap do |p|- p.master.prices.delete_all- p.master.set_price('EUR', 20.0)+ p.default_variant.prices.delete_all+ p.default_variant.set_price('EUR', 20.0)endend@@ -190,13 +190,13 @@ RSpec.describe Spree::Api::V3::Store::ProductsController, type: :controller docontext 'sorting' dolet!(:cheap_product) docreate(:product, status: 'active', name: 'Cheap').tap do |p|- p.master.prices.first.update!(amount: 10.0)+ p.default_variant.prices.first.update!(amount: 10.0)endendlet!(:expensive_product) docreate(:product, status: 'active', name: 'Expensive').tap do |p|- p.master.prices.first.update!(amount: 100.0)+ p.default_variant.prices.first.update!(amount: 100.0)endenddiff --git a/spree/api/spec/integration/spree/api/v3/admin/price_lists_spec.rb b/spree/api/spec/integration/spree/api/v3/admin/price_lists_spec.rbindex 99b9baa42b..8591b8a293 100644--- a/spree/api/spec/integration/spree/api/v3/admin/price_lists_spec.rb+++ b/spree/api/spec/integration/spree/api/v3/admin/price_lists_spec.rb@@ -155,7 +155,7 @@ RSpec.describe 'Admin Price Lists API', type: :request, swagger_doc: 'api-refere# referenced in `prices` implicitly become part of the list.let(:'x-spree-api-key') { secret_api_key.plaintext_token }let(:product) { create(:product) }- let(:variant_a) { product.master }+ let(:variant_a) { product.default_variant }let(:variant_b) { create(:variant, product: product) }let(:body) do{@@ -353,7 +353,7 @@ RSpec.describe 'Admin Price Lists API', type: :request, swagger_doc: 'api-referelet(:'x-spree-api-key') { secret_api_key.plaintext_token }let(:id) { price_list.prefixed_id }let(:product) { create(:product) }- let(:variant) { product.master }+ let(:variant) { product.default_variant }let!(:placeholder) docreate(:price, variant: variant, price_list: price_list, currency: 'USD', amount: nil)enddiff --git a/spree/api/spec/integration/spree/api/v3/admin/prices_spec.rb b/spree/api/spec/integration/spree/api/v3/admin/prices_spec.rbindex c3962eb2fe..8eab3642e8 100644--- a/spree/api/spec/integration/spree/api/v3/admin/prices_spec.rb+++ b/spree/api/spec/integration/spree/api/v3/admin/prices_spec.rb@@ -8,10 +8,6 @@ RSpec.describe 'Admin Prices API', type: :request, swagger_doc: 'api-reference/alet(:Authorization) { "Bearer #{admin_jwt_token}" }let(:price_list) { create(:price_list, store: store) }let(:product) { create(:product) }- # Use a non-master variant from the start. Touching the master while- # also creating sibling variants later in the example triggers the- # `remove_prices_from_master_variant` callback (variant.rb), which- # `delete_all`s the master's prices and would silently wipe our seed.let!(:variant) { create(:variant, product: product) }let!(:list_price) docreate(:price, variant: variant, price_list: price_list, currency: 'USD', amount: 5.0)diff --git a/spree/api/spec/integration/spree/api/v3/admin/variants_spec.rb b/spree/api/spec/integration/spree/api/v3/admin/variants_spec.rbindex 104bf1fd66..c24010aa48 100644--- a/spree/api/spec/integration/spree/api/v3/admin/variants_spec.rb+++ b/spree/api/spec/integration/spree/api/v3/admin/variants_spec.rb@@ -14,7 +14,7 @@ RSpec.describe 'Admin Variants API', type: :request, swagger_doc: 'api-referencetags 'Variants'produces 'application/json'security [api_key: [], bearer_auth: []]- description 'Returns a paginated list of variants for a product, including the master variant.'+ description 'Returns a paginated list of variants for a product, including the default variant.'admin_scope :read, :productsadmin_sdk_example 'variants/list'@@ -62,7 +62,6 @@ RSpec.describe 'Admin Variants API', type: :request, swagger_doc: 'api-referenceparameter name: :product_id, in: :path, type: :string, required: true, description: 'Product ID'parameter name: :body, in: :body, schema: {type: :object,- required: %w[options],properties: {sku: { type: :string, example: 'SKU-001' },cost_price: { type: :string, example: '10.00' },@@ -77,7 +76,7 @@ RSpec.describe 'Admin Variants API', type: :request, swagger_doc: 'api-referencetax_category_id: { type: :string },options: {type: :array,- description: 'Required. A variant created here is always non-master, so it must declare at least one option pair (e.g. size + color) or creation fails with 422. One pair per option type the variant participates in. Option types and values are auto-created if missing.',+ description: 'A variant on a product with option types should declare its option pairs (e.g. size + color) — one per option type it participates in. Option types and values are auto-created if missing.',items: {type: :object,required: %w[name value],@@ -129,12 +128,11 @@ RSpec.describe 'Admin Variants API', type: :request, swagger_doc: 'api-referenceendend- # A variant created here is always non-master, so omitting `options`- # leaves it with no option values and fails validation.+ # Reusing an existing variant's SKU violates the uniqueness validation.response '422', 'validation error' dolet(:'x-spree-api-key') { secret_api_key.plaintext_token }let(:product_id) { product.prefixed_id }- let(:body) { { sku: 'NO-OPTS-001', prices: [{ currency: 'USD', amount: '9.99' }] } }+ let(:body) { { sku: variant.sku, prices: [{ currency: 'USD', amount: '9.99' }] } }schema '$ref' => '#/components/schemas/ErrorResponse'diff --git a/spree/api/spec/integration/spree/api/v3/store/digitals_spec.rb b/spree/api/spec/integration/spree/api/v3/store/digitals_spec.rbindex 47d8ea91f7..dc4d1d2f0d 100644--- a/spree/api/spec/integration/spree/api/v3/store/digitals_spec.rb+++ b/spree/api/spec/integration/spree/api/v3/store/digitals_spec.rb@@ -6,7 +6,7 @@ RSpec.describe 'Digitals API', type: :request, swagger_doc: 'api-reference/storeinclude_context 'API v3 Store'let(:product) { create(:product) }- let(:order) { create(:order_with_line_items, store: store, user: user, line_items_attributes: [{ variant: product.master, quantity: 1 }]) }+ let(:order) { create(:order_with_line_items, store: store, user: user, line_items_attributes: [{ variant: product.default_variant, quantity: 1 }]) }let(:line_item) { order.line_items.first }let(:digital) { create(:digital, variant: line_item.variant) }let!(:digital_link) { create(:digital_link, digital: digital, line_item: line_item) }diff --git a/spree/api/spec/integration/spree/api/v3/store/line_items_spec.rb b/spree/api/spec/integration/spree/api/v3/store/line_items_spec.rbindex b665a7c1d6..66eb173453 100644--- a/spree/api/spec/integration/spree/api/v3/store/line_items_spec.rb+++ b/spree/api/spec/integration/spree/api/v3/store/line_items_spec.rb@@ -7,7 +7,7 @@ RSpec.describe 'Cart Items API', type: :request, swagger_doc: 'api-reference/stolet!(:order) { create(:order, store: store, user: user) }let!(:product) { create(:product) }- let!(:variant) { product.master }+ let!(:variant) { product.default_variant }let!(:line_item) { create(:line_item, order: order, variant: variant, quantity: 1) }let(:cart_id) { order.prefixed_id }@@ -41,7 +41,7 @@ RSpec.describe 'Cart Items API', type: :request, swagger_doc: 'api-reference/storesponse '201', 'item added, returns updated cart' dolet(:new_product) { create(:product) }- let(:new_variant) { new_product.master }+ let(:new_variant) { new_product.default_variant }let(:'x-spree-api-key') { api_key.token }let(:'Authorization') { "Bearer #{jwt_token}" }let(:body) { { variant_id: new_variant.prefixed_id, quantity: 2 } }@@ -58,7 +58,7 @@ RSpec.describe 'Cart Items API', type: :request, swagger_doc: 'api-reference/storesponse '201', 'item added with metadata' dolet(:new_product) { create(:product) }- let(:new_variant) { new_product.master }+ let(:new_variant) { new_product.default_variant }let(:'x-spree-api-key') { api_key.token }let(:'Authorization') { "Bearer #{jwt_token}" }let(:body) { { variant_id: new_variant.prefixed_id, quantity: 1, metadata: { gift_message: 'Happy Birthday!' } } }diff --git a/spree/api/spec/integration/spree/api/v3/store/products_spec.rb b/spree/api/spec/integration/spree/api/v3/store/products_spec.rbindex 5ac26e7412..d3f66c04fd 100644--- a/spree/api/spec/integration/spree/api/v3/store/products_spec.rb+++ b/spree/api/spec/integration/spree/api/v3/store/products_spec.rb@@ -165,7 +165,7 @@ RSpec.describe 'Products API', type: :request, swagger_doc: 'api-reference/storebefore do# Set up price history on all variant prices to ensure the# default_variant's price has history regardless of which variant is selected- product.variants_including_master.each do |v|+ product.variants.each do |v|v.prices.base_prices.each do |price|price.price_histories.delete_allcreate(:price_history, price: price, variant: v, amount: 25.0, currency: price.currency, recorded_at: 1.day.ago)diff --git a/spree/api/spec/integration/spree/api/v3/store/wishlists_spec.rb b/spree/api/spec/integration/spree/api/v3/store/wishlists_spec.rbindex d01b868eff..3bff92b539 100644--- a/spree/api/spec/integration/spree/api/v3/store/wishlists_spec.rb+++ b/spree/api/spec/integration/spree/api/v3/store/wishlists_spec.rb@@ -7,7 +7,7 @@ RSpec.describe 'Wishlists API', type: :request, swagger_doc: 'api-reference/storlet!(:wishlist) { create(:wishlist, user: user, store: store, name: 'My Wishlist') }let!(:product) { create(:product) }- let!(:variant) { product.master }+ let!(:variant) { product.default_variant }let!(:wished_item) { create(:wished_item, wishlist: wishlist, variant: variant) }path '/api/v3/store/wishlists' do@@ -215,7 +215,7 @@ RSpec.describe 'Wishlists API', type: :request, swagger_doc: 'api-reference/storresponse '201', 'item added' dolet(:new_product) { create(:product) }- let(:new_variant) { new_product.master }+ let(:new_variant) { new_product.default_variant }let(:'x-spree-api-key') { api_key.token }let(:'Authorization') { "Bearer #{jwt_token}" }let(:wishlist_id) { wishlist.to_param }diff --git a/spree/api/spec/serializers/spree/api/v3/asset_serializer_spec.rb b/spree/api/spec/serializers/spree/api/v3/asset_serializer_spec.rbindex 60a936b890..ef31b65024 100644--- a/spree/api/spec/serializers/spree/api/v3/asset_serializer_spec.rb+++ b/spree/api/spec/serializers/spree/api/v3/asset_serializer_spec.rb@@ -5,7 +5,7 @@ require 'spec_helper'RSpec.describe Spree::Api::V3::AssetSerializer dolet(:store) { @default_store }let(:product) { create(:product) }- let(:asset) { create(:asset, viewable: product.master) }+ let(:asset) { create(:asset, viewable: product.default_variant) }let(:base_params) { { store: store, currency: 'USD' } }subject { described_class.new(asset, params: base_params).to_h }@@ -21,7 +21,7 @@ RSpec.describe Spree::Api::V3::AssetSerializer doendit 'returns prefixed viewable_id' do- expect(subject['viewable_id']).to eq(product.master.prefixed_id)+ expect(subject['viewable_id']).to eq(product.default_variant.prefixed_id)endit 'returns viewable_type' dodiff --git a/spree/api/spec/serializers/spree/api/v3/line_item_serializer_spec.rb b/spree/api/spec/serializers/spree/api/v3/line_item_serializer_spec.rbindex f18976e0cc..36235262cf 100644--- a/spree/api/spec/serializers/spree/api/v3/line_item_serializer_spec.rb+++ b/spree/api/spec/serializers/spree/api/v3/line_item_serializer_spec.rb@@ -70,7 +70,7 @@ RSpec.describe Spree::Api::V3::LineItemSerializer docontext 'when variant has no image but product has an image' dolet(:image) { create(:image) }- let(:variant) { product.master }+ let(:variant) { product.default_variant }before doproduct.images << imagediff --git a/spree/api/spec/serializers/spree/api/v3/price_serializer_spec.rb b/spree/api/spec/serializers/spree/api/v3/price_serializer_spec.rbindex b12c8f5823..cf958a14e1 100644--- a/spree/api/spec/serializers/spree/api/v3/price_serializer_spec.rb+++ b/spree/api/spec/serializers/spree/api/v3/price_serializer_spec.rb@@ -3,7 +3,7 @@ require 'spec_helper'RSpec.describe Spree::Api::V3::PriceSerializer dolet(:store) { @default_store }let(:product) { create(:product, price: 19.99) }- let(:variant) { product.master }+ let(:variant) { product.default_variant }let(:price) { variant.prices.first }let(:base_params) { { store: store, currency: 'USD' } }@@ -44,7 +44,7 @@ endRSpec.describe Spree::Api::V3::Admin::PriceSerializer dolet(:store) { @default_store }let(:product) { create(:product, price: 19.99) }- let(:variant) { product.master }+ let(:variant) { product.default_variant }let(:price) { variant.prices.first }let(:base_params) { { store: store, currency: 'USD' } }