Skip to content

Instantly share code, notes, and snippets.

@schof
Created December 16, 2011 03:34
Show Gist options
  • Select an option

  • Save schof/1484325 to your computer and use it in GitHub Desktop.

Select an option

Save schof/1484325 to your computer and use it in GitHub Desktop.
Latest tax rate specs
require 'spec_helper'
describe Spree::TaxRate do
context 'validation' do
it { should validate_presence_of(:tax_category_id) }
end
context "match" do
let(:zone) { Factory(:zone) }
let(:order) { Factory(:order) }
let(:tax_category) { Factory(:tax_category) }
let(:calculator) { Spree::Calculator::FlatRate.new }
it "should return an empty array when tax_zone is nil" do
order.stub :tax_zone => nil
Spree::TaxRate.match(order).should == []
end
it "should return an emtpy array when no rate zones match the tax_zone" do
Spree::TaxRate.create :amount => 1, :zone => Factory(:zone, :name => 'other_zone')
order.stub :tax_zone => zone
Spree::TaxRate.match(order).should == []
end
it "should return the rate that matches the rate zone" do
rate = Spree::TaxRate.create :amount => 1, :zone => zone, :tax_category => tax_category,
:calculator => calculator
order.stub :tax_zone => zone
Spree::TaxRate.match(order).should == [rate]
end
it "should return all rates that match the rate zone" do
rate1 = Spree::TaxRate.create :amount => 1, :zone => zone, :tax_category => tax_category,
:calculator => calculator
rate2 = Spree::TaxRate.create :amount => 2, :zone => zone, :tax_category => tax_category,
:calculator => calculator
order.stub :tax_zone => zone
Spree::TaxRate.match(order).should == [rate1, rate2]
end
end
context "#adjust" do
context "when order has no taxable line items" do
pending "should not create a tax adjustment"
pending "should not create a price adjustment"
pending "should not create a refund"
end
context "when order has one taxable line item" do
context "when price includes tax" do
context "when zone is contained by default tax zone" do
pending "should create one price adjustment"
pending "should not create a refund"
pending "should not create a tax adjustment"
end
context "when zone is not contained by default tax zone" do
pending "should not create a price adjustment"
pending "should create a tax refund"
pending "should not create a tax adjustment"
end
end
context "when price does not include tax" do
pending "should not create price adjustments"
pending "should not create tax refund"
pending "should create a tax adjustment"
end
end
context "when order has multiple taxable line items" do
context "when price includes tax" do
context "when zone is contained by default tax zone" do
pending "should create multiple price adjustments"
pending "should not create a refund"
pending "should not create a tax adjustment"
end
context "when zone is not contained by default tax zone" do
pending "should not create a price adjustment"
pending "should create a single tax refund"
pending "should create a single tax adjustment"
end
end
context "when price does not include tax" do
pending "should not create price adjustment"
pending "should not create tax refund"
pending "should create a single tax adjustment"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment