Skip to content

Commit

Permalink
Adds out of stock check as helper
Browse files Browse the repository at this point in the history
As shared examoples, in guest_spec.rb
  • Loading branch information
filipefurtad0 committed Apr 30, 2024
1 parent 0f80aca commit 729c5f0
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions spec/system/consumer/checkout/guest_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,30 @@
end
end
end

shared_examples "when a line item is out of stock" do |session, step|
context "as a #{session} user" do
let(:user) { create(:user) }
before do
variant.on_demand = false
variant.on_hand = 0
variant.save!

if session == "logged"
login_as(user)
end
end
it "returns me to the cart with an error message" do
out_of_stock_check(step)
end
end
end

it_behaves_like "when a line item is out of stock", "guest", "details"
it_behaves_like "when a line item is out of stock", "guest", "payment"
it_behaves_like "when a line item is out of stock", "guest", "summary"

it_behaves_like "when a line item is out of stock", "logged", "details"
it_behaves_like "when a line item is out of stock", "logged", "payment"
it_behaves_like "when a line item is out of stock", "logged", "summary"
end

0 comments on commit 729c5f0

Please sign in to comment.