From a42c9499797d2b14e34744214fcbf571c989ce9d Mon Sep 17 00:00:00 2001 From: marlena-b Date: Mon, 16 Sep 2024 14:21:56 +0200 Subject: [PATCH] Change service to be 'void' type, change test --- rails_application/app/services/orders/submit_service.rb | 7 +++---- .../test/services/orders/submit_service_test.rb | 7 ++++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/rails_application/app/services/orders/submit_service.rb b/rails_application/app/services/orders/submit_service.rb index e4eba9a1..84c6889c 100644 --- a/rails_application/app/services/orders/submit_service.rb +++ b/rails_application/app/services/orders/submit_service.rb @@ -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 diff --git a/rails_application/test/services/orders/submit_service_test.rb b/rails_application/test/services/orders/submit_service_test.rb index 96542571..3c0048fd 100644 --- a/rails_application/test/services/orders/submit_service_test.rb +++ b/rails_application/test/services/orders/submit_service_test.rb @@ -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