Sha256: ee9b7a15fde5f3b884cdb0775737a3be7e588b7784416c516ce921ddae555b18

Contents?: true

Size: 870 Bytes

Versions: 6

Compression:

Stored size: 870 Bytes

Contents

require 'test_helper'

class FlatPercentItemTotalTest < ActiveSupport::TestCase
  context "Calculator::FlatPercentItemTotal" do
    [Coupon, ShippingMethod].each do |calculable| 
      should "be available to #{calculable.to_s}" do
       assert calculable.calculators.include?(Calculator::FlatPercentItemTotal)
      end
    end
    should "not be available to TaxRate" do
      assert !TaxRate.calculators.include?(Calculator::FlatPercentItemTotal)
    end

    context "compute" do
      setup do
        @order = Factory(:order)
        @order.item_total = 123
        @calculator = Calculator::FlatPercentItemTotal.new(:preferred_flat_percent => 10)
      end

      context "apply the percentage rate" do
        should "compute ten percent" do
          assert_equal((123 * 10 / 100.0), @calculator.compute(@order))
        end
      end       
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
spree-enriquez-0.9.4 test/unit/flat_percent_item_total_test.rb
spree-0.9.4 test/unit/flat_percent_item_total_test.rb
spree-0.9.3 test/unit/flat_percent_item_total_test.rb
spree-0.9.2 test/unit/flat_percent_item_total_test.rb
spree-0.9.1 test/unit/flat_percent_item_total_test.rb
spree-0.9.0 test/unit/flat_percent_item_total_test.rb