mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-06 02:51:34 +00:00
34 lines
1.1 KiB
Ruby
34 lines
1.1 KiB
Ruby
module Spree
|
|
describe TaxRate do
|
|
describe "selecting tax rates to apply to an order" do
|
|
let!(:zone) { create(:zone_with_member) }
|
|
let!(:order) { create(:order, distributor: hub, bill_address: create(:address)) }
|
|
let!(:tax_rate) { create(:tax_rate, included_in_price: true, calculator: Calculator::FlatRate.new(preferred_amount: 0.1), zone: zone) }
|
|
|
|
describe "when the order's hub charges sales tax" do
|
|
let(:hub) { create(:distributor_enterprise, charges_sales_tax: true) }
|
|
|
|
it "selects all tax rates" do
|
|
TaxRate.match(order).should == [tax_rate]
|
|
end
|
|
end
|
|
|
|
describe "when the order's hub does not charge sales tax" do
|
|
let(:hub) { create(:distributor_enterprise, charges_sales_tax: false) }
|
|
|
|
it "selects no tax rates" do
|
|
TaxRate.match(order).should be_empty
|
|
end
|
|
end
|
|
|
|
describe "when the order does not have a hub" do
|
|
let!(:order) { create(:order, distributor: nil, bill_address: create(:address)) }
|
|
|
|
it "selects all tax rates" do
|
|
TaxRate.match(order).should == [tax_rate]
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|