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.

Initial Price List status should be draft

Damian Legawiecd9afa1ac713d
diff --git a/core/app/models/spree/price_list.rb b/core/app/models/spree/price_list.rb
index 9994d5beb4..a338506539 100644
--- a/core/app/models/spree/price_list.rb
+++ b/core/app/models/spree/price_list.rb
@@ -44,7 +44,7 @@ module Spree
.where('ends_at IS NULL OR ends_at >= ?', current_time)
}
- state_machine :status do
+ state_machine :status, initial: :draft do
event :activate do
transition to: :active
end
diff --git a/core/db/migrate/20251110120000_create_spree_price_lists.rb b/core/db/migrate/20251110120000_create_spree_price_lists.rb
index 22b319a5c8..1ebee2caed 100644
--- a/core/db/migrate/20251110120000_create_spree_price_lists.rb
+++ b/core/db/migrate/20251110120000_create_spree_price_lists.rb
@@ -5,7 +5,7 @@ class CreateSpreePriceLists < ActiveRecord::Migration[7.0]
t.string :name, null: false
t.text :description
t.integer :position, null: false, default: 0
- t.string :status, null: false, default: 'active'
+ t.string :status, null: false, default: 'draft'
t.datetime :starts_at
t.datetime :ends_at
t.string :match_policy, null: false, default: 'all'
diff --git a/core/lib/spree/testing_support/factories/price_list_factory.rb b/core/lib/spree/testing_support/factories/price_list_factory.rb
index 2053c4155d..588a8267f4 100644
--- a/core/lib/spree/testing_support/factories/price_list_factory.rb
+++ b/core/lib/spree/testing_support/factories/price_list_factory.rb
@@ -3,7 +3,10 @@ FactoryBot.define do
sequence(:name) { |n| "Price List #{n}" }
store { Spree::Store.default || create(:store) }
match_policy { 'all' }
- status { 'active' }
+
+ trait :draft do
+ status { 'draft' }
+ end
trait :active do
status { 'active' }
diff --git a/core/spec/models/spree/price_list_spec.rb b/core/spec/models/spree/price_list_spec.rb
index 2825f0287a..694ded71b4 100644
--- a/core/spec/models/spree/price_list_spec.rb
+++ b/core/spec/models/spree/price_list_spec.rb
@@ -15,8 +15,8 @@ describe Spree::PriceList, type: :model do
describe 'state_machine' do
let(:price_list) { create(:price_list) }
- it 'has initial status of active' do
- expect(price_list.status).to eq('active')
+ it 'has initial status of draft' do
+ expect(price_list.status).to eq('draft')
end
describe '#activate' do