Skip to content

armgit / spree

Public Imported from GitHub
0

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.

Carry the stock level rename through the leftovers

Łukasz Adamczyke85d19c09568
diff --git a/docs/plans/6.0-admin-api.md b/docs/plans/6.0-admin-api.md
index 80e9f7141d..e01f542272 100644
--- a/docs/plans/6.0-admin-api.md
+++ b/docs/plans/6.0-admin-api.md
@@ -140,7 +140,7 @@ Per-record conditions (CanCanCan blocks/hashes) are not serialized — only `has
### Infrastructure (done)
- Base controllers, resource controller, admin authentication, JWT with admin audience, secret API key auth (with [scopes](5.5-admin-api-key-scopes.md)), httpOnly refresh-cookie auth, prefixed IDs, error handling, Pagy, Ransack, CanCanCan scoping, per-action bulk-operation helper (`Spree::Api::V3::BulkOperations`), `custom_fieldable` route concern, Active Storage direct uploads — all in place.
-- Admin serializers exist for Product, Variant, Price, PriceList, Order, LineItem, Fulfillment, Payment, Refund, Adjustment, Customer, Address, CreditCard, StoreCredit, CustomerGroup, GiftCard, GiftCardBatch, Category, OptionType, OptionValue, Promotion, PromotionAction, PromotionRule, CouponCode, PaymentMethod, Channel, Market, Country, TaxCategory, StockLocation, StockItem, StockReservation, StockTransfer, Store, AdminUser, Role, Invitation, ApiKey, AllowedOrigin, WebhookEndpoint, WebhookDelivery, Export, CustomFieldDefinition, CustomField, Tag. More are added as endpoints come online.
+- Admin serializers exist for Product, Variant, Price, PriceList, Order, LineItem, Fulfillment, Payment, Refund, Adjustment, Customer, Address, CreditCard, StoreCredit, CustomerGroup, GiftCard, GiftCardBatch, Category, OptionType, OptionValue, Promotion, PromotionAction, PromotionRule, CouponCode, PaymentMethod, Channel, Market, Country, TaxCategory, StockLocation, StockLevel, StockMovement, StockReservation, StockTransfer, Store, AdminUser, Role, Invitation, ApiKey, AllowedOrigin, WebhookEndpoint, WebhookDelivery, Export, CustomFieldDefinition, CustomField, Tag. More are added as endpoints come online.
### Endpoint rollout order
@@ -637,16 +637,19 @@ Customer assignment is handled via the standard `PATCH /api/v3/admin/orders/:id`
- [x] `PATCH /api/v3/admin/stock_locations/:id`
- [x] `DELETE /api/v3/admin/stock_locations/:id`
-### Stock Items
-- [x] `GET /api/v3/admin/stock_items` — filterable by stock_location, variant
-- [x] `GET /api/v3/admin/stock_items/:id`
-- [x] `PATCH /api/v3/admin/stock_items/:id`
-- [x] `DELETE /api/v3/admin/stock_items/:id`
+### Stock Levels
+- [x] `GET /api/v3/admin/stock_levels` — filterable by stock_location, variant
+- [x] `GET /api/v3/admin/stock_levels/:id`
+- [x] `PATCH /api/v3/admin/stock_levels/:id` — a count edit is written as an `adjusted` movement, and takes an optional `reason`
+- [x] `DELETE /api/v3/admin/stock_levels/:id`
+
+> **6.0:** renamed from `stock_items`, prefix `si_` → `sl_`. No route alias is kept. See `6.0-typed-stock-movements.md`.
### Stock Movements (read-only; typed in 6.0)
-- [ ] `GET /api/v3/admin/stock_movements` — filterable by `kind`, `fulfillment_id`, `order_id`, `return_id`, `stock_transfer_id`
+- [x] `GET /api/v3/admin/stock_movements` — filterable by `kind`, `stock_level_id`, `fulfillment_id`, `order_id`, `return_id`, `exchange_id`, `stock_transfer_id`
+- [x] `GET /api/v3/admin/stock_movements/:id`
-> **6.0:** `StockMovement` gains `kind` enum (`received`, `allocated`, `shipped`, `released`, `adjusted`) + concrete FKs to the originating event. See `6.0-typed-stock-movements.md`.
+> **6.0:** `StockMovement` carries a `kind` (`received`, `allocated`, `shipped`, `released`, `adjusted`) + concrete FKs to the originating event. Read-only by route — there is no create, update or destroy. See `6.0-typed-stock-movements.md`.
### Stock Reservations (read-only; new in 6.0)
- [x] `GET /api/v3/admin/stock_reservations` — filterable by variant, order, cart
diff --git a/docs/plans/6.0-admin-rbac.md b/docs/plans/6.0-admin-rbac.md
index 098f270771..5ddfaddf0f 100644
--- a/docs/plans/6.0-admin-rbac.md
+++ b/docs/plans/6.0-admin-rbac.md
@@ -272,7 +272,7 @@ Core registers one entry per resource of the current scope vocabulary:
| `products` | Catalog | Product, ProductType, Variant, OptionType, OptionValue, Price, PriceList, PriceRule, Asset, ProductPublication |
| `categories` | Catalog | Category, Taxonomy, ProductCategory |
| `collections` | Catalog | Collection, ProductCollection, CollectionRule |
-| `stock` | Catalog | StockItem, StockLocation, StockMovement, StockTransfer, StockReservation |
+| `stock` | Catalog | StockLevel, StockLocation, StockMovement, StockTransfer, StockReservation |
| `promotions` | Marketing | Promotion, PromotionRule, PromotionAction, PromotionCategory, CouponCode |
| `customers` | Customers | `Spree.customer_class`, Address, CreditCard, CustomerGroup |
| `settings` | Settings | Store, PaymentMethod, DeliveryMethod, DeliveryZone, Market, Channel, TaxCategory, TaxRate, reasons, MetafieldDefinition, Policy, AllowedOrigin, OrderRoutingRule, … (today's ConfigurationManagement list minus webhooks) |
diff --git a/docs/plans/6.0-inventory-operations.md b/docs/plans/6.0-inventory-operations.md
index f11eb08757..20a4e6a072 100644
--- a/docs/plans/6.0-inventory-operations.md
+++ b/docs/plans/6.0-inventory-operations.md
@@ -411,7 +411,7 @@ State-transition endpoints are explicit POSTs (not PATCHes that mutate `status`)
### Phase 0 (prerequisite)
-`6.0-typed-stock-movements.md` lands first — the `kind` column, concrete FKs, allocated_count column on StockItem, and StockMovement model rewrite. Without this, transfers and POs can't write typed audit rows.
+`6.0-typed-stock-movements.md` lands first — the `kind` column, concrete FKs, allocated_count column on StockLevel, and StockMovement model rewrite. Without this, transfers and POs can't write typed audit rows.
### Phase 1: Schema
diff --git a/docs/plans/6.0-typed-stock-movements.md b/docs/plans/6.0-typed-stock-movements.md
index b8aa396a87..437c2bd830 100644
--- a/docs/plans/6.0-typed-stock-movements.md
+++ b/docs/plans/6.0-typed-stock-movements.md
@@ -1,10 +1,10 @@
# Typed Stock Movements
-**Status:** Design Finalized
+**Status:** Phases 0–4 implemented (2026-08-19); Phase 5 is 6.1 cleanup
**Target:** Spree 6.0 (polymorphic `originator` dropped in 6.1)
**Depends on:** Fulfillment & Delivery (6.0-fulfillment-and-delivery.md), Cart/Order Split (6.0-cart-order-split.md), Returns/Exchanges/Claims (6.0-returns-exchanges-claims.md), Stock Reservations (6.0-stock-reservations.md), Store-Scoped Configuration (6.0-store-scoped-configuration.md)
**Author:** Damian + Claude
-**Last updated:** 2026-08-13
+**Last updated:** 2026-08-19
> **Scope note (2026-08-13):** this plan now owns the `Spree::StockItem` → `Spree::StockLevel` rename (decisions.md 2026-03-17), which had no owning plan. It ships as **Phase 0**, ahead of the new columns, so they are born beside a final name instead of needing a second pass. Everything from Phase 0 onward reads `StockLevel` / `stock_level_id` / `spree_stock_levels`; the Current State table and the data migration's legacy references keep today's names.
@@ -355,7 +355,7 @@ Response:
Phase order follows the repo convention: schema first, then behavior, then the data transformation, and every destructive drop waits for 6.1. The data task reads `originator_type`/`originator_id`, so dropping those columns before it runs would leave installs with no way to type their history — that is why the drop is last rather than second.
-### Phase 0: `StockItem` → `StockLevel`
+### Phase 0: `StockItem` → `StockLevel` ✅ shipped
A pure rename, shipped on its own so the review is a diff of names rather than a diff of names tangled with new stock semantics. No data is transformed, so there is no rake task and nothing for the manifest.
@@ -386,7 +386,7 @@ API and TypeScript side:
- `@spree/admin-sdk`: `StockItem` → `StockLevel`, `client.stockItems` → `client.stockLevels`, with a changeset calling the break out. Then the dashboard's `use-stock-items` hook, the stock-coverage hook, the inventory and variants sections, the stock-locations route and the inventory e2e spec.
- The 5.6 → 6.0 upgrade guide gains a rename section covering the class, the endpoint, the SDK resource, the prefix change and the dual-emitted events, and every bridge goes into its "Deprecated in 6.0, removed in 6.1" list so nobody has to read this plan to find out what disappears next release.
-### Phase 1: Schema (additive)
+### Phase 1: Schema (additive) ✅ shipped
```ruby
class AddTypedStockMovements < ActiveRecord::Migration[8.1]
@@ -410,7 +410,7 @@ end
`kind` is nullable here and gains its `NOT NULL` in 6.1, once the data task has had a release to run — the same pattern as the store-ownership columns added earlier in 6.0. The model validates its presence regardless, so every row written by 6.0 code is typed.
-### Phase 2: Model and call sites
+### Phase 2: Model and call sites ✅ shipped
The behavior change, shipped as one unit because a half-converted call site double-counts stock:
@@ -422,7 +422,7 @@ The behavior change, shipped as one unit because a half-converted call site doub
- Route the admin `PATCH /stock_levels` count edit and `Variant#set_stock` through `adjusted` movements.
- Drop `Quantifier.allocated_count_column?`.
-### Phase 3: Data migration (`spree:migrate_stock_movements_to_typed_rows`)
+### Phase 3: Data migration (`spree:migrate_stock_movements_to_typed_rows`) ✅ shipped
Two jobs in one idempotent task, added to the 5.6 → 6.0 manifest.
@@ -450,7 +450,7 @@ Backordered units need no special case: the pair of increments cancels out the n
Idempotency comes from the data itself. Typing skips rows that already have a kind; reconciliation skips fulfillments that already have an `allocated` movement. That same predicate is what makes the deploy window safe: a fulfillment shipped before the task runs never gets an allocation, and `Fulfillments::Fulfill` writes `shipped` only for allocated units, so its stock is not decremented twice.
-### Phase 4: API, serializer, dashboard
+### Phase 4: API, serializer, dashboard ✅ shipped
- New read-only `stock_movements` admin endpoint with the Ransack allowlist above; `kind` and the FKs on the serializer, `originator_*` off it.
- `reason` permitted on `PATCH /stock_levels`.
diff --git a/docs/plans/decisions.md b/docs/plans/decisions.md
index ddd59504ff..bfb7de5e95 100644
--- a/docs/plans/decisions.md
+++ b/docs/plans/decisions.md
@@ -226,7 +226,7 @@ to the stock ledger at all. Typed Stock Movements splits the two: placement
writes an `allocated` movement that raises `allocated_count` and leaves
`count_on_hand` untouched, and dispatch writes a `shipped` movement that
decrements `count_on_hand` and retires the allocation with it. On-hand becomes what is on the shelf and
-`StockItem#allocated_count` carries what is promised, which is the model every
+`StockLevel#allocated_count` carries what is promised, which is the model every
other commerce platform ships.
Three consequences worth naming, because they change existing behavior rather
diff --git a/packages/admin-sdk/tests/stock.test.ts b/packages/admin-sdk/tests/stock.test.ts
index fde20632b6..648d776316 100644
--- a/packages/admin-sdk/tests/stock.test.ts
+++ b/packages/admin-sdk/tests/stock.test.ts
@@ -4,7 +4,7 @@ import { API_PREFIX, createTestClient, paginated } from './helpers'
import { server } from './mocks/server'
const sampleStockLocation = {
- id: 'sl_abc123',
+ id: 'sloc_abc123',
name: 'Main Warehouse',
default: true,
active: true,
@@ -17,7 +17,7 @@ const sampleStockLevel = {
count_on_hand: 42,
backorderable: false,
variant_id: 'variant_1',
- stock_location_id: 'sl_abc123',
+ stock_location_id: 'sloc_abc123',
created_at: '2026-05-01T00:00:00Z',
updated_at: '2026-05-01T00:00:00Z',
}
@@ -40,8 +40,8 @@ const sampleStockMovement = {
const sampleStockTransfer = {
id: 'st_abc123',
number: 'T123456789',
- source_location_id: 'sl_abc123',
- destination_location_id: 'sl_def456',
+ source_location_id: 'sloc_abc123',
+ destination_location_id: 'sloc_def456',
created_at: '2026-05-01T00:00:00Z',
updated_at: '2026-05-01T00:00:00Z',
}
@@ -58,7 +58,7 @@ describe('stockLocations', () => {
const res = await createTestClient().stockLocations.list()
expect(res.data).toHaveLength(1)
- expect(res.data[0]?.id).toBe('sl_abc123')
+ expect(res.data[0]?.id).toBe('sloc_abc123')
})
it('wraps Ransack predicates via transformListParams', async () => {
@@ -81,17 +81,17 @@ describe('stockLocations', () => {
it('GETs /stock_locations/:id and forwards expand params', async () => {
let url: URL | null = null
server.use(
- http.get(`${API_PREFIX}/stock_locations/sl_abc123`, ({ request }) => {
+ http.get(`${API_PREFIX}/stock_locations/sloc_abc123`, ({ request }) => {
url = new URL(request.url)
return HttpResponse.json(sampleStockLocation)
}),
)
- const res = await createTestClient().stockLocations.get('sl_abc123', {
+ const res = await createTestClient().stockLocations.get('sloc_abc123', {
expand: ['stock_levels'],
})
- expect(res.id).toBe('sl_abc123')
+ expect(res.id).toBe('sloc_abc123')
expect(url!.searchParams.get('expand')).toBe('stock_levels')
})
})
@@ -114,13 +114,13 @@ describe('stockLocations', () => {
it('PATCHes the update body verbatim', async () => {
let body: Record<string, unknown> | null = null
server.use(
- http.patch(`${API_PREFIX}/stock_locations/sl_abc123`, async ({ request }) => {
+ http.patch(`${API_PREFIX}/stock_locations/sloc_abc123`, async ({ request }) => {
body = (await request.json()) as Record<string, unknown>
return HttpResponse.json({ ...sampleStockLocation, active: false })
}),
)
- const res = await createTestClient().stockLocations.update('sl_abc123', { active: false })
+ const res = await createTestClient().stockLocations.update('sloc_abc123', { active: false })
expect(body).toEqual({ active: false })
expect(res.active).toBe(false)
@@ -129,13 +129,13 @@ describe('stockLocations', () => {
it('DELETEs /stock_locations/:id', async () => {
let hit = false
server.use(
- http.delete(`${API_PREFIX}/stock_locations/sl_abc123`, () => {
+ http.delete(`${API_PREFIX}/stock_locations/sloc_abc123`, () => {
hit = true
return new HttpResponse(null, { status: 204 })
}),
)
- await expect(createTestClient().stockLocations.delete('sl_abc123')).resolves.toBeUndefined()
+ await expect(createTestClient().stockLocations.delete('sloc_abc123')).resolves.toBeUndefined()
expect(hit).toBe(true)
})
})
@@ -166,11 +166,11 @@ describe('stockLevels', () => {
)
await createTestClient().stockLevels.list({
- stock_location_id_eq: 'sl_abc123',
+ stock_location_id_eq: 'sloc_abc123',
variant_id_eq: 'variant_1',
})
- expect(url!.searchParams.get('q[stock_location_id_eq]')).toBe('sl_abc123')
+ expect(url!.searchParams.get('q[stock_location_id_eq]')).toBe('sloc_abc123')
expect(url!.searchParams.get('q[variant_id_eq]')).toBe('variant_1')
})
})
@@ -249,11 +249,11 @@ describe('stockTransfers', () => {
await createTestClient().stockTransfers.list({
number_cont: 'T123',
- source_location_id_eq: 'sl_abc123',
+ source_location_id_eq: 'sloc_abc123',
})
expect(url!.searchParams.get('q[number_cont]')).toBe('T123')
- expect(url!.searchParams.get('q[source_location_id_eq]')).toBe('sl_abc123')
+ expect(url!.searchParams.get('q[source_location_id_eq]')).toBe('sloc_abc123')
})
})
@@ -287,13 +287,13 @@ describe('stockTransfers', () => {
)
await createTestClient().stockTransfers.create({
- source_location_id: 'sl_abc123',
- destination_location_id: 'sl_def456',
+ source_location_id: 'sloc_abc123',
+ destination_location_id: 'sloc_def456',
})
expect(body).toEqual({
- source_location_id: 'sl_abc123',
- destination_location_id: 'sl_def456',
+ source_location_id: 'sloc_abc123',
+ destination_location_id: 'sloc_def456',
})
})
diff --git a/packages/dashboard/src/locales/en.json b/packages/dashboard/src/locales/en.json
index 30f774b786..f36b695bed 100644
--- a/packages/dashboard/src/locales/en.json
+++ b/packages/dashboard/src/locales/en.json
@@ -1244,11 +1244,11 @@
"placeholder": "Optional — shown only in the admin"
},
"backorderable_default": {
- "help": "New stock items default to allowing backorders when out of stock.",
+ "help": "New stock levels default to allowing backorders when out of stock.",
"label": "Backorderable by default"
},
"default": {
- "help": "New stock items propagate here. Only one location can be default.",
+ "help": "New stock levels propagate here. Only one location can be default.",
"label": "Default location"
},
"kind": {
@@ -1273,8 +1273,8 @@
"label": "Stock policy"
},
"propagate_all_variants": {
- "help": "Create stock items at this location for every product variant.",
- "label": "Auto-create stock items for all variants"
+ "help": "Create stock levels at this location for every product variant.",
+ "label": "Auto-create stock levels for all variants"
}
},
"store": {
@@ -3894,7 +3894,7 @@
"create_description": "Add a warehouse, store, or pickup point to fulfill orders from.",
"create_label": "Create stock location",
"delete_confirm": {
- "message": "{{name}} will be removed. Stock items at this location are not deleted.",
+ "message": "{{name}} will be removed. Stock levels at this location are not deleted.",
"title": "Delete stock location?"
},
"edit_description": "Update name, address, pickup, or stock policies.",
diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/settings/stock-locations.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/settings/stock-locations.tsx
index e98a06ab46..5188e92e05 100644
--- a/packages/dashboard/src/routes/_authenticated/$storeId/settings/stock-locations.tsx
+++ b/packages/dashboard/src/routes/_authenticated/$storeId/settings/stock-locations.tsx
@@ -325,7 +325,7 @@ function EditStockLocationSheet({
}
// ============================================================================
-// Stock Items panel — adjust on-hand counts at this location
+// Stock Levels panel — adjust on-hand counts at this location
// ============================================================================
function StockLevelsPanel({ stockLocationId }: { stockLocationId: string }) {
diff --git a/spree/api/app/serializers/spree/api/v3/admin/stock_level_serializer.rb b/spree/api/app/serializers/spree/api/v3/admin/stock_level_serializer.rb
index a1798d0c99..0fc6b0f5f7 100644
--- a/spree/api/app/serializers/spree/api/v3/admin/stock_level_serializer.rb
+++ b/spree/api/app/serializers/spree/api/v3/admin/stock_level_serializer.rb
@@ -9,8 +9,9 @@ module Spree
attributes :metadata,
created_at: :iso8601, updated_at: :iso8601
- # Units already allocated to pending shipments. Always 0 in 5.5;
- # 6.0 Typed Stock Movements wires it up.
+ # Units promised to placed orders but not yet dispatched. Raised by an
+ # `allocated` movement and retired by `released` or `shipped`, so an
+ # oversell reads as this exceeding count_on_hand.
attribute :allocated_count do |stock_level|
stock_level.allocated_count.to_i
end
diff --git a/spree/core/app/models/spree/order_routing/strategy/rules.rb b/spree/core/app/models/spree/order_routing/strategy/rules.rb
index 8b162cde79..aaf8dd3e83 100644
--- a/spree/core/app/models/spree/order_routing/strategy/rules.rb
+++ b/spree/core/app/models/spree/order_routing/strategy/rules.rb
@@ -42,7 +42,7 @@ module Spree
def eligible_locations
order.store.stock_locations.active
.joins(:stock_levels)
- .where(spree_stock_levels: { variant_id: requested_variant_ids })
+ .where(Spree::StockLevel.table_name => { variant_id: requested_variant_ids })
.distinct
.to_a
end
diff --git a/spree/core/app/models/spree/stock/coordinator.rb b/spree/core/app/models/spree/stock/coordinator.rb
index 47c2784456..713bbd2d35 100644
--- a/spree/core/app/models/spree/stock/coordinator.rb
+++ b/spree/core/app/models/spree/stock/coordinator.rb
@@ -43,7 +43,7 @@ module Spree
def stock_locations_with_requested_variants
order.store.stock_locations.active.joins(:stock_levels).
- where(spree_stock_levels: { variant_id: requested_variant_ids }).distinct
+ where(Spree::StockLevel.table_name => { variant_id: requested_variant_ids }).distinct
end
# An item may only be allocated from locations its delivery profile
diff --git a/spree/core/app/models/spree/stock_transfer.rb b/spree/core/app/models/spree/stock_transfer.rb
index 98b1a5f440..b1ffe7b878 100644
--- a/spree/core/app/models/spree/stock_transfer.rb
+++ b/spree/core/app/models/spree/stock_transfer.rb
@@ -85,7 +85,8 @@ module Spree
private
def find_stock_location_with_location_id(location_id)
- stock_movements.joins(:stock_level).where('spree_stock_levels.stock_location_id' => location_id)
+ stock_movements.joins(:stock_level).
+ where(Spree::StockLevel.table_name => { stock_location_id: location_id })
end
def source_location_is_not_destination_location
diff --git a/spree/core/spec/models/spree/product/shared_catalog_spec.rb b/spree/core/spec/models/spree/product/shared_catalog_spec.rb
index 33633e3412..c305f40a92 100644
--- a/spree/core/spec/models/spree/product/shared_catalog_spec.rb
+++ b/spree/core/spec/models/spree/product/shared_catalog_spec.rb
@@ -88,7 +88,7 @@ describe Spree::Product, type: :model do
it 'still names a variant when nothing is buyable, so the page has a price' do
out_of_stock = create(:variant, product: product, seller: seller, sku: 'S-1', price: 5)
- out_of_stock.stock_items.update_all(count_on_hand: 0, backorderable: false)
+ out_of_stock.stock_levels.update_all(count_on_hand: 0, backorderable: false)
expect(product.reload.buy_box_variant).to eq(out_of_stock)
end
@@ -128,11 +128,11 @@ describe Spree::Product, type: :model do
it 'is in stock through a variant priced only in another currency' do
empty = create(:variant, product: product, sku: 'A-1', price: 10)
- empty.stock_items.update_all(count_on_hand: 0, backorderable: false)
+ empty.stock_levels.update_all(count_on_hand: 0, backorderable: false)
stocked = create(:variant, product: product, sku: 'B-1', price: nil)
stocked.prices.destroy_all
stocked.set_price('EUR', 9)
- stocked.stock_items.update_all(count_on_hand: 5)
+ stocked.stock_levels.update_all(count_on_hand: 5)
Spree::Current.currency = 'USD'
expect(product.reload).to be_in_stock
@@ -157,7 +157,7 @@ describe Spree::Product, type: :model do
suspended = create(:seller, :suspended, store: store)
create(:variant, product: product, seller: suspended, sku: 'S-1', price: 5)
ours = create(:variant, product: product, sku: 'O-1', price: 5)
- ours.stock_items.update_all(count_on_hand: 0, backorderable: false)
+ ours.stock_levels.update_all(count_on_hand: 0, backorderable: false)
expect(product.reload).not_to be_purchasable
end
diff --git a/spree/core/spec/services/spree/products/select_buy_box_spec.rb b/spree/core/spec/services/spree/products/select_buy_box_spec.rb
index a134fbf0b5..159573280a 100644
--- a/spree/core/spec/services/spree/products/select_buy_box_spec.rb
+++ b/spree/core/spec/services/spree/products/select_buy_box_spec.rb
@@ -36,7 +36,7 @@ describe Spree::Products::SelectBuyBox do
it 'passes over an out-of-stock variant for one that can be bought' do
empty = create(:variant, product: product, seller: seller, sku: 'S-1', price: 5)
- empty.stock_items.update_all(count_on_hand: 0, backorderable: false)
+ empty.stock_levels.update_all(count_on_hand: 0, backorderable: false)
available = create(:variant, product: product, seller: other_seller, sku: 'S-2', price: 50)
expect(winner).to eq(available)
@@ -66,7 +66,7 @@ describe Spree::Products::SelectBuyBox do
suspended = create(:seller, :suspended, store: store)
create(:variant, product: product, seller: suspended, sku: 'X-1', price: 1)
active_empty = create(:variant, product: product, seller: seller, sku: 'S-1', price: 50)
- active_empty.stock_items.update_all(count_on_hand: 0, backorderable: false)
+ active_empty.stock_levels.update_all(count_on_hand: 0, backorderable: false)
expect(winner).to eq(active_empty)
end