Skip to content

Commit

Permalink
Cover vat rate
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszreszke committed Jul 29, 2024
1 parent 13cb420 commit 954863a
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions rails_application/test/integration/products_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 954863a

Please sign in to comment.