-
-
Notifications
You must be signed in to change notification settings - Fork 707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updates checkout tests to cover for out of stock variant #12423
Merged
mkllnk
merged 4 commits into
openfoodfoundation:master
from
filipefurtad0:legacy_checkout_migrate_checkout_spec
May 7, 2024
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
Comment on lines
+304
to
+306
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of this conditional, you could just do the login in a context block outside of the shared examples. |
||
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 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the method name ambiguous. Does it check that something is out of stock or that nothing is out of stock?
When a test helper is mainly asserting expectations, I use that in the name. What about
expect_out_of_stock
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming is indeed a whole science on its own. Thanks for that tip 馃檹