Sha256: d4b0062bc9af62bbb8c2f3329e97b9952c3c82886e3d25bac5da27e9e43c7ca7

Contents?: true

Size: 1.23 KB

Versions: 34

Compression:

Stored size: 1.23 KB

Contents

require 'test_helper'

module Workarea
  module Pricing
    class PriceTest < TestCase
      def sku
        @sku ||= Sku.new(id: 'SKU')
      end

      def test_validation_callback
        price = sku.prices.build(regular: nil)
        price.valid?
        assert_equal(0.to_m, price.regular)
      end

      def test_sell
        assert_equal(4.to_m, sku.prices.build(regular: 4).sell)

        sku.on_sale = true
        price = sku.prices.build(regular: 4, sale: 3)
        assert_equal(3.to_m, price.sell)

        sku.on_sale = false
        price = sku.prices.build(regular: 4)
        assert_equal(4.to_m, price.sell)
      end

      def test_generic
        price = Price.new
        assert(price.generic?)

        price.min_quantity = 2
        refute(price.generic?)
      end

      def test_on_sale
        price = sku.prices.build
        refute(price.on_sale?)

        sku.on_sale = true
        price.on_sale = true
        assert(price.on_sale?)

        sku.on_sale = true
        price.on_sale = false
        assert(price.on_sale?)

        sku.on_sale = false
        price.on_sale = true
        assert(price.on_sale?)

        sku.on_sale = false
        price.on_sale = false
        refute(price.on_sale?)
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
workarea-core-3.4.45 test/models/workarea/pricing/price_test.rb
workarea-core-3.4.44 test/models/workarea/pricing/price_test.rb
workarea-core-3.4.43 test/models/workarea/pricing/price_test.rb
workarea-core-3.4.42 test/models/workarea/pricing/price_test.rb
workarea-core-3.4.41 test/models/workarea/pricing/price_test.rb
workarea-core-3.4.40 test/models/workarea/pricing/price_test.rb
workarea-core-3.4.39 test/models/workarea/pricing/price_test.rb
workarea-core-3.4.38 test/models/workarea/pricing/price_test.rb
workarea-core-3.4.37 test/models/workarea/pricing/price_test.rb
workarea-core-3.4.36 test/models/workarea/pricing/price_test.rb
workarea-core-3.4.35 test/models/workarea/pricing/price_test.rb
workarea-core-3.4.34 test/models/workarea/pricing/price_test.rb
workarea-core-3.4.33 test/models/workarea/pricing/price_test.rb
workarea-core-3.4.32 test/models/workarea/pricing/price_test.rb
workarea-core-3.4.31 test/models/workarea/pricing/price_test.rb
workarea-core-3.4.30 test/models/workarea/pricing/price_test.rb
workarea-core-3.4.29 test/models/workarea/pricing/price_test.rb
workarea-core-3.4.28 test/models/workarea/pricing/price_test.rb
workarea-core-3.4.27 test/models/workarea/pricing/price_test.rb
workarea-core-3.4.26 test/models/workarea/pricing/price_test.rb