diff --git a/app/models/spree/adjustment_decorator.rb b/app/models/spree/adjustment_decorator.rb index 8447d24046..a8272acb0f 100644 --- a/app/models/spree/adjustment_decorator.rb +++ b/app/models/spree/adjustment_decorator.rb @@ -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 diff --git a/spec/models/spree/adjustment_spec.rb b/spec/models/spree/adjustment_spec.rb index bd952f2e9c..512e720f54 100644 --- a/spec/models/spree/adjustment_spec.rb +++ b/spec/models/spree/adjustment_spec.rb @@ -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