Check whether an individual adjustment has tax included

This commit is contained in:
Rohan Mitchell
2015-10-15 09:58:06 +11:00
parent b22d591775
commit 92f7b72056
2 changed files with 23 additions and 7 deletions

View File

@@ -20,5 +20,9 @@ module Spree
def set_absolute_included_tax!(tax)
update_attributes! included_tax: tax.round(2)
end
def has_tax?
included_tax > 0
end
end
end

View File

@@ -5,18 +5,30 @@ module Spree
adjustment.metadata.should be
end
describe "finding adjustments with and without tax included" do
describe "querying included tax" do
let!(:adjustment_with_tax) { create(:adjustment, included_tax: 123) }
let!(:adjustment_without_tax) { create(:adjustment, included_tax: 0) }
it "finds adjustments with tax" do
Adjustment.with_tax.should include adjustment_with_tax
Adjustment.with_tax.should_not include adjustment_without_tax
describe "finding adjustments with and without tax included" do
it "finds adjustments with tax" do
Adjustment.with_tax.should include adjustment_with_tax
Adjustment.with_tax.should_not include adjustment_without_tax
end
it "finds adjustments without tax" do
Adjustment.without_tax.should include adjustment_without_tax
Adjustment.without_tax.should_not include adjustment_with_tax
end
end
it "finds adjustments without tax" do
Adjustment.without_tax.should include adjustment_without_tax
Adjustment.without_tax.should_not include adjustment_with_tax
describe "checking if an adjustment includes tax" do
it "returns true when it has > 0 tax" do
adjustment_with_tax.should have_tax
end
it "returns false when it has 0 tax" do
adjustment_without_tax.should_not have_tax
end
end
end