Extends spec coverage of Tax Rates settings - CRUD operations

This commit is contained in:
filipefurtad0
2020-12-21 19:16:16 +00:00
committed by Matt-Yorkley
parent 381d5a5e37
commit 3edf5fd6d9

View File

@@ -1,12 +1,12 @@
# frozen_string_literal: true
require 'spec_helper'
describe "Tax Rates" do
include AuthenticationHelper
let!(:calculator) { create(:calculator_per_item, calculable: create(:order)) }
let!(:tax_rate) { create(:tax_rate, calculator: calculator) }
let!(:tax_rate) { create(:tax_rate, name: "IVA", calculator: calculator) }
let!(:zone_id) { create(:zone, name: "Ilhas") }
let!(:tax_category_id) { create(:tax_category, name: "Full") }
before do
login_as_admin_and_visit spree.edit_admin_general_settings_path
@@ -29,4 +29,37 @@ describe "Tax Rates" do
click_button "Create"
expect(page).to have_content("Tax rate has been successfully created!")
end
# Adds further CRUD operations: editing, deleting
context "while editing" do
it "fields can be filled in and dropfdowns retains changes" do
visit spree.edit_admin_tax_rate_path(tax_rate.id)
fill_in "Rate", with: "0.23"
fill_in "Name", with: "GST"
find(:id, "tax_rate_zone_id").select "Ilhas"
find(:id, "tax_rate_tax_category_id").select "Full"
click_button "Update"
expect(page).to have_content('Tax rate "GST" has been successfully updated!')
expect(page).to have_content("0.23")
end
# See #6554: in order to set a Tax Rate as included in the price,
# there must be at least one Zone set the "Default Tax Zone"
it "checkboxes can be ticked" do
visit spree.edit_admin_tax_rate_path(tax_rate.id)
uncheck("tax_rate[show_rate_in_label]")
check("tax_rate[included_in_price]")
click_button "Update"
expect(page).to have_content("Included Price Validation")
end
it "can be deleted", js: true do
click_link "Tax Rates"
accept_alert do
find(:xpath, "/html/body/div[1]/div[3]/div/div/div/table/tbody/tr[1]/td[8]/a[2]").click
end
expect(page).not_to have_content("IVA")
end
end
end