diff --git a/app/helpers/checkout_helper.rb b/app/helpers/checkout_helper.rb index cd986eb565..c1139b63f9 100644 --- a/app/helpers/checkout_helper.rb +++ b/app/helpers/checkout_helper.rb @@ -18,20 +18,24 @@ module CheckoutHelper end def display_checkout_admin_and_handling_adjustments_total_for(order) - adjustments = order.adjustments.eligible.where('originator_type = ? AND source_type != ? ', 'EnterpriseFee', 'Spree::LineItem' ) - Spree::Money.new( adjustments.sum( &:amount ) , { :currency => order.currency }) + adjustments = order.adjustments.eligible.where('originator_type = ? AND source_type != ? ', 'EnterpriseFee', 'Spree::LineItem') + Spree::Money.new adjustments.sum(&:amount) , currency: order.currency end def checkout_line_item_adjustments(order) - order.adjustments.eligible.where( source_type: "Spree::LineItem") + order.adjustments.eligible.where(source_type: "Spree::LineItem") end def checkout_subtotal(order) - order.item_total + checkout_line_item_adjustments(order).sum( &:amount ) + order.item_total + checkout_line_item_adjustments(order).sum(&:amount) end def display_checkout_subtotal(order) - Spree::Money.new( checkout_subtotal(order) , { :currency => order.currency }) + Spree::Money.new checkout_subtotal(order) , currency: order.currency + end + + def display_checkout_tax_total(order) + Spree::Money.new order.total_tax, currency: order.currency end def checkout_state_options(source_address) diff --git a/spec/helpers/checkout_helper_spec.rb b/spec/helpers/checkout_helper_spec.rb index c4979be40d..e47a5e8c51 100644 --- a/spec/helpers/checkout_helper_spec.rb +++ b/spec/helpers/checkout_helper_spec.rb @@ -12,4 +12,12 @@ describe CheckoutHelper do helper.validated_input("test", "foo", type: :email) end + + describe "displaying the tax total for an order" do + let(:order) { double(:order, total_tax: 123.45, currency: 'AUD') } + + it "retrieves the total tax on the order" do + helper.display_checkout_tax_total(order).should == Spree::Money.new(123.45, currency: 'AUD') + end + end end