mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-28 06:15:17 +00:00
Replace zoned_order factory with zone_with_member. In practice, former had issues with circular dependencies.
This commit is contained in:
@@ -183,14 +183,11 @@ FactoryGirl.define do
|
||||
end
|
||||
end
|
||||
|
||||
factory :zoned_order, :parent => :order do
|
||||
after(:create) do |order|
|
||||
zone = create(:zone, default_tax: true)
|
||||
factory :zone_with_member, :parent => :zone do
|
||||
default_tax true
|
||||
|
||||
after(:create) do |zone|
|
||||
Spree::ZoneMember.create!(zone: zone, zoneable: Spree::Country.find_by_name('Australia'))
|
||||
unless order.bill_address
|
||||
order.bill_address = create(:address)
|
||||
order.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -113,9 +113,10 @@ feature %q{
|
||||
let(:user2) { create_enterprise_user enterprises: [create(:distributor_enterprise, with_payment_and_shipping: true)] }
|
||||
let(:shipping_method) { create(:shipping_method, name: "Shipping", description: "Expensive", calculator: Spree::Calculator::FlatRate.new(preferred_amount: 100.55)) }
|
||||
|
||||
let(:order1) { create(:zoned_order, distributor: user1.enterprises.first, shipping_method: shipping_method) }
|
||||
let(:product1) { create(:taxed_product, zone: order1.tax_zone, price: 12.54, tax_rate_amount: 0) }
|
||||
let(:product2) { create(:taxed_product, zone: order1.tax_zone, price: 500.15, tax_rate_amount: 0.2) }
|
||||
let!(:zone) { create(:zone_with_member) }
|
||||
let(:order1) { create(:order, distributor: user1.enterprises.first, shipping_method: shipping_method, bill_address: create(:address)) }
|
||||
let(:product1) { create(:taxed_product, zone: zone, price: 12.54, tax_rate_amount: 0) }
|
||||
let(:product2) { create(:taxed_product, zone: zone, price: 500.15, tax_rate_amount: 0.2) }
|
||||
|
||||
let!(:line_item1) { create(:line_item, variant: product1.master, price: 12.54, quantity: 1, order: order1) }
|
||||
let!(:line_item2) { create(:line_item, variant: product2.master, price: 500.15, quantity: 3, order: order1) }
|
||||
|
||||
@@ -7,7 +7,8 @@ module Spree
|
||||
|
||||
describe "recording included tax" do
|
||||
describe "TaxRate adjustments" do
|
||||
let!(:order) { create(:zoned_order) }
|
||||
let!(:zone) { create(:zone_with_member) }
|
||||
let!(:order) { create(:order, bill_address: create(:address)) }
|
||||
let!(:line_item) { create(:line_item, order: order) }
|
||||
let(:tax_rate) { create(:tax_rate, included_in_price: true, calculator: Calculator::FlatRate.new(preferred_amount: 0.1)) }
|
||||
let(:adjustment) { line_item.adjustments(:reload).first }
|
||||
@@ -83,8 +84,7 @@ module Spree
|
||||
end
|
||||
|
||||
describe "EnterpriseFee adjustments" do
|
||||
let!(:zone) { create(:zone, default_tax: true) }
|
||||
let!(:zone_member) { ZoneMember.create!(zone: zone, zoneable: Country.find_by_name('Australia')) }
|
||||
let!(:zone) { create(:zone_with_member) }
|
||||
let(:tax_rate) { create(:tax_rate, included_in_price: true, calculator: Calculator::DefaultTax.new, zone: zone, amount: 0.1) }
|
||||
let(:tax_category) { create(:tax_category, tax_rates: [tax_rate]) }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user