From 954863aeaa6f5136c8bb12a16d320f7d2476f9f6 Mon Sep 17 00:00:00 2001 From: lukaszreszke Date: Mon, 29 Jul 2024 10:51:19 +0200 Subject: [PATCH] Cover vat rate --- .../test/integration/products_test.rb | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/rails_application/test/integration/products_test.rb b/rails_application/test/integration/products_test.rb index 813a79eb..5144f2f9 100644 --- a/rails_application/test/integration/products_test.rb +++ b/rails_application/test/integration/products_test.rb @@ -59,4 +59,59 @@ def test_does_not_crash_when_setting_products_price_to_0 assert_response :unprocessable_entity assert_select "span", "Price must be greater than 0" end + + def test_does_not_crash_when_vat_rate_is_absent + register_customer("Arkency") + product_id = SecureRandom.uuid + + get "/products/new" + assert_select "h1", "New Product" + post "/products", + params: { + "authenticity_token" => "[FILTERED]", + "product_id" => product_id, + "name" => "product name", + "price" => "100", + } + + assert_response :unprocessable_entity + assert_select "span", "Vat rate can't be blank" + end + + def test_does_not_crash_when_vat_rate_is_not_a_number + register_customer("Arkency") + product_id = SecureRandom.uuid + + get "/products/new" + assert_select "h1", "New Product" + post "/products", + params: { + "authenticity_token" => "[FILTERED]", + "product_id" => product_id, + "name" => "product name", + "price" => "100", + "vat_rate" =>"abc" + } + + assert_response :unprocessable_entity + assert_select "span", "Vat rate is not a number" + end + + def test_does_not_crash_when_name_is_not_present + register_customer("Arkency") + product_id = SecureRandom.uuid + + get "/products/new" + assert_select "h1", "New Product" + post "/products", + params: { + "authenticity_token" => "[FILTERED]", + "product_id" => product_id, + "price" => "100", + "vat_rate" =>"10" + } + + assert_response :unprocessable_entity + assert_select "span", "Name can't be blank" + end end