Skip to content

Commit

Permalink
Fix problem in order factory
Browse files Browse the repository at this point in the history
We dont need the global zone
  • Loading branch information
luisramos0 committed Aug 23, 2020
1 parent f627741 commit ee158e8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
13 changes: 6 additions & 7 deletions spec/factories/order_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,19 @@
product_price 0
tax_rate_amount 0
tax_rate_name ""
zone { create(:zone_with_member) }
end

distributor { create(:distributor_enterprise) }
order_cycle { create(:simple_order_cycle) }

after(:create) do |order, proxy|
order.distributor.update_attribute(:charges_sales_tax, true)
Spree::Zone.global.update_attribute(:default_tax, true)

p = FactoryBot.create(:taxed_product, zone: Spree::Zone.global,
price: proxy.product_price,
tax_rate_amount: proxy.tax_rate_amount,
tax_rate_name: proxy.tax_rate_name)
FactoryBot.create(:line_item, order: order, product: p, price: p.price)
product = FactoryBot.create(:taxed_product, zone: zone,
price: proxy.product_price,
tax_rate_amount: proxy.tax_rate_amount,
tax_rate_name: proxy.tax_rate_name)
FactoryBot.create(:line_item, order: order, product: product, price: product.price)
order.reload
end
end
Expand Down
5 changes: 2 additions & 3 deletions spec/services/tax_rate_finder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
let(:included_tax) { BigDecimal(20) }
let(:tax_rate) { create_rate(0.2) }
let(:tax_category) { create(:tax_category, tax_rates: [tax_rate]) }
# This zone is used by :order_with_taxes and needs to match it
let(:zone) { create(:zone, name: "GlobalZone") }
let(:zone) { create(:zone_with_member) }
let(:shipment) { create(:shipment) }
let(:enterprise_fee) { create(:enterprise_fee, tax_category: tax_category) }
let(:order) { create(:order_with_taxes) }
let(:order) { create(:order_with_taxes, zone: zone) }

it "finds the tax rate of a shipping fee" do
rates = TaxRateFinder.new.tax_rates(
Expand Down

0 comments on commit ee158e8

Please sign in to comment.