-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0845c39
commit ff3f3cc
Showing
6 changed files
with
31 additions
and
20 deletions.
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
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 |
---|---|---|
|
@@ -10,3 +10,5 @@ def promote_to_vip | |
update!(vip: true) | ||
end | ||
end | ||
|
||
class AlreadyVip < StandardError; end |
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
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 |
---|---|---|
|
@@ -74,16 +74,16 @@ def before_teardown | |
result | ||
end | ||
|
||
def register_customer(name) | ||
customer_id = SecureRandom.uuid | ||
post "/customers", params: { customer_id: customer_id, name: name } | ||
customer_id | ||
def register_customer(name, email = "[email protected]") | ||
post "/customers", params: { customer: { first_name: name, last_name: "", email: } } | ||
Customer.find_by(email:).id | ||
end | ||
|
||
def register_product(name, price, vat_rate) | ||
product_id = SecureRandom.uuid | ||
post "/products", params: { product_id: product_id, name: name, price: price, vat_rate: vat_rate } | ||
product_id | ||
def register_product(name, price, vat_rate, sku = SecureRandom.uuid, stock_level: 10) | ||
post "/products", params: { product: { name: name, price: price, vat_rate: vat_rate, sku: } } | ||
product = Product.find_by(sku:) | ||
post "/products/#{product.id}/supplies", params: { product_id: product.id, quantity: stock_level } | ||
product.id | ||
end | ||
|
||
def supply_product(product_id, quantity) | ||
|
@@ -111,7 +111,7 @@ def submit_order(customer_id, order_id) | |
"order_id" => order_id, | ||
"customer_id" => customer_id, | ||
"commit" => "Submit order" | ||
} | ||
} | ||
end | ||
|
||
def visit_customers_index | ||
|
@@ -134,6 +134,11 @@ def add_product_to_basket(order_id, product_id) | |
post "/orders/#{order_id}/add_item?product_id=#{product_id}" | ||
end | ||
|
||
def new_order | ||
get "/orders/new" | ||
Order.last | ||
end | ||
|
||
def run_command(command) | ||
Rails.configuration.command_bus.call(command) | ||
end | ||
|