From df26d62146196b66b111cf8cc59d4ead62fc9345 Mon Sep 17 00:00:00 2001 From: marlena-b Date: Mon, 16 Sep 2024 12:03:43 +0200 Subject: [PATCH] Add test --- .../test/integration/orders_test.rb | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/rails_application/test/integration/orders_test.rb b/rails_application/test/integration/orders_test.rb index 327d75c9..d091bc2e 100644 --- a/rails_application/test/integration/orders_test.rb +++ b/rails_application/test/integration/orders_test.rb @@ -219,6 +219,27 @@ def test_order_cannot_be_submitted_with_out_of_stock_product assert_equal "Order can not be submitted! Fearless Refactoring not available in requested quantity!", flash[:alert] end + def test_current_time_promotion_is_applied + order_id = SecureRandom.uuid + async_remote_id = register_product("Async Remote", 39, 10) + shopify_id = register_customer("Shopify") + + create_current_time_promotion + post "/orders/#{order_id}/add_item?product_id=#{async_remote_id}" + + post "/orders", + params: { + "authenticity_token" => "[FILTERED]", + "order_id" => order_id, + "customer_id" => shopify_id, + "commit" => "Submit order" + } + follow_redirect! + + assert_select("td", "$19.50") + assert_select("dd", "Submitted") + end + private def assert_remove_buttons_visible(async_remote_id, fearless_id, order_id) @@ -329,4 +350,13 @@ def apply_discount_10_percent(order_id) post "/orders/#{order_id}/update_discount?amount=10" end + + def create_current_time_promotion(discount: 50, start_time: Time.current - 1.day, end_time: Time.current + 1.day) + post "/time_promotions", params: { + label: "Last Minute", + discount: discount, + start_time: start_time, + end_time: end_time + } + end end