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.

Update `Spree::Core::ControllerHelpers::Store` specs (#12967)

Łukasz Adamczyk061cfc1b4fa4
diff --git a/core/spec/lib/spree/core/controller_helpers/store_spec.rb b/core/spec/lib/spree/core/controller_helpers/store_spec.rb
index 224eef1c94..dfc92fa277 100644
--- a/core/spec/lib/spree/core/controller_helpers/store_spec.rb
+++ b/core/spec/lib/spree/core/controller_helpers/store_spec.rb
@@ -53,7 +53,7 @@ describe Spree::Core::ControllerHelpers::Store, type: :controller do
before { allow(controller).to receive(:current_store).and_return(store) }
context 'when the object has no stores associated' do
- object = Spree::Product.new
+ let(:object) { build(:product, stores: []) }
it 'associates the object with the current_store' do
controller.ensure_current_store(object)
@@ -63,24 +63,18 @@ describe Spree::Core::ControllerHelpers::Store, type: :controller do
end
context 'when the object has a store pre assigned' do
- object = Spree::Product.new
-
- it 'adds the new store without removing the orgional store' do
- object.stores << store_2
- object.save
+ let(:object) { create(:product, stores: [store_2]) }
+ it 'adds the new store without removing the original store' do
controller.ensure_current_store(object)
expect(object.stores).to contain_exactly(store, store_2)
end
end
context 'when the object has a store and the same store is attempted to be added' do
- object = Spree::Product.new
+ let(:object) { create(:product, stores: [store]) }
it 'object is not changed' do
- object.stores << store
- object.save
-
controller.ensure_current_store(object)
expect(object.stores).to contain_exactly(store)
end