Skip to content

Commit

Permalink
fix product_spec.rb: #7
Browse files Browse the repository at this point in the history
after create callbacks. VCR must know with stock requests when creating products.
  • Loading branch information
Pauloparakleto committed Dec 22, 2023
1 parent cbd0a0b commit 7e3bffb
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions spec/models/product_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 7e3bffb

Please sign in to comment.