Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Result pattern to exceptions #395

Merged
merged 2 commits into from
Sep 17, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Change service to be 'void' type, change test
marlena-b committed Sep 16, 2024
commit d1c12afc72e1ed1c8597654dace668a1b7f8cdd3
7 changes: 3 additions & 4 deletions rails_application/app/services/orders/submit_service.rb
Original file line number Diff line number Diff line change
@@ -22,10 +22,9 @@ def call
end
.call

if unavailable_products.any?
raise OrderHasUnavailableProducts.new(unavailable_products)
end
true
if unavailable_products.any?
raise OrderHasUnavailableProducts.new(unavailable_products)
end
end

private
Original file line number Diff line number Diff line change
@@ -13,7 +13,12 @@ def test_successful_order_submission
prepare_product(product_id, "Async Remote", 49)
run_command(Ordering::AddItemToBasket.new(order_id: order_id, product_id: product_id))

assert_equal true, Orders::SubmitService.new(order_id: order_id, customer_id: customer_id).call
Orders::SubmitService.new(order_id: order_id, customer_id: customer_id).call

order = Order.find_by!(uid: order_id)

assert_equal "Submitted", order.state
assert_equal "John Doe", order.customer
end

def test_order_submission_with_unavailable_products