diff --git a/lib/tasks/sample_data/addressing.rb b/lib/tasks/sample_data/addressing.rb index 3db2753b71..1728933994 100644 --- a/lib/tasks/sample_data/addressing.rb +++ b/lib/tasks/sample_data/addressing.rb @@ -16,8 +16,10 @@ module Addressing end def zone - zone = Spree::Zone.find_or_create_by!(name: ENV.fetch('CHECKOUT_ZONE')) - zone.members.create!(zoneable: country) unless zone.zoneables.include?(country) + zone = Spree::Zone.find_or_create_by(name: ENV.fetch('CHECKOUT_ZONE')) + zone.members << Spree::ZoneMember.create(zoneable: country) unless + zone.zoneables.include?(country) + zone.save! zone end diff --git a/spec/helpers/spree/base_helper_spec.rb b/spec/helpers/spree/base_helper_spec.rb index 050b1b61f2..4f57acecf8 100644 --- a/spec/helpers/spree/base_helper_spec.rb +++ b/spec/helpers/spree/base_helper_spec.rb @@ -26,9 +26,8 @@ RSpec.describe Spree::BaseHelper do context "with a checkout zone defined" do context "checkout zone is of type country" do before do - @country_zone = create(:zone, name: "CountryZone") - @country_zone.members.create(zoneable: country) - allow(ENV).to receive(:fetch).and_return(@country_zone.name) + country_zone = create(:zone, name: "CountryZone", member: country) + allow(ENV).to receive(:fetch).and_return(country_zone.name) end it "return only the countries defined by the checkout zone" do diff --git a/spec/models/invoice/data_presenter_spec.rb b/spec/models/invoice/data_presenter_spec.rb index 555aeeb952..4c76cb2e4e 100644 --- a/spec/models/invoice/data_presenter_spec.rb +++ b/spec/models/invoice/data_presenter_spec.rb @@ -61,9 +61,10 @@ RSpec.describe Invoice::DataPresenter do expect(presenter.display_line_item_tax_rate(taxable_line_item)).to eq "15.0%, 20.0%" end - context "one of the tax rate is appliable to a different tax zone" do + context "one of the tax rate is applicable to a different tax zone" do before do - order.line_items.last.tax_category.tax_rates.last.update!(zone: create(:zone)) + new_zone = create(:zone, default_tax: false, member: Spree::Country.last) + order.line_items.last.tax_category.tax_rates.last.update!(zone: new_zone) order.create_tax_charge! Orders::GenerateInvoiceService.new(order).generate_or_update_latest_invoice end diff --git a/spec/system/admin/configuration/tax_rates_spec.rb b/spec/system/admin/configuration/tax_rates_spec.rb index 87c60b2392..6e26fddd03 100644 --- a/spec/system/admin/configuration/tax_rates_spec.rb +++ b/spec/system/admin/configuration/tax_rates_spec.rb @@ -6,8 +6,10 @@ RSpec.describe "Tax Rates" do include AuthenticationHelper let!(:calculator) { create(:calculator_per_item, calculable: create(:order)) } - let!(:tax_rate) { create(:tax_rate, name: "IVA", calculator:) } - let!(:zone) { create(:zone, name: "Ilhas") } + let!(:tax_rate) { + create(:tax_rate, name: "IVA", calculator:, zone: create(:zone, default_tax: false)) + } + let!(:zone) { create(:zone, name: "Ilhas", default_tax: false) } let!(:tax_category) { create(:tax_category, name: "Full") } before do