From 7e3bffb4c40a40c4e6549d4be20a5131875bb115 Mon Sep 17 00:00:00 2001 From: Paulo Felipe Silva de Souza Date: Thu, 21 Dec 2023 22:59:10 -0300 Subject: [PATCH] fix product_spec.rb: #7 after create callbacks. VCR must know with stock requests when creating products. --- spec/models/product_spec.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/spec/models/product_spec.rb b/spec/models/product_spec.rb index 2cf0261b..083a4251 100644 --- a/spec/models/product_spec.rb +++ b/spec/models/product_spec.rb @@ -56,7 +56,7 @@ include_context 'when user account' it 'creates stock' do - VCR.use_cassette('bling_stocks', erb: true) do + VCR.use_cassette('bling_products_with_stock_by_product_ids', erb: true) do expect do FactoryBot.create(:product, bling_id:, account_id: user.account.id) end.to change(Stock, :count).by(1) @@ -71,7 +71,7 @@ context 'when there is no product' do it 'counts by 100' do - VCR.use_cassette('bling_products', erb: true) do + VCR.use_cassette('bling_products_with_stock_by_product_ids', erb: true) do expect do described_class.synchronize_bling(user.account.id) end.to change(described_class, :count).by(100) @@ -84,10 +84,14 @@ include_context 'when user account' - before { FactoryBot.create(:product, bling_id: bling_product_id, account_id: user.account.id) } + before do + VCR.use_cassette('bling_products_with_stock_by_product_ids', erb: true) do + FactoryBot.create(:product, bling_id: bling_product_id, account_id: user.account.id) + end + end it 'counts by 99' do - VCR.use_cassette('bling_products', erb: true) do + VCR.use_cassette('bling_products_with_stock_by_product_ids', erb: true) do expect do described_class.synchronize_bling(user.account.id) end.to change(described_class, :count).by(99) @@ -97,7 +101,7 @@ context 'when attributes' do before do - VCR.use_cassette('bling_products', erb: true) do + VCR.use_cassette('bling_products_with_stock_by_product_ids', erb: true) do described_class.synchronize_bling(user.account.id) end end