Files
openfoodnetwork/spec/models/spree/tax_rate_spec.rb
2015-04-17 13:41:38 +10:00

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