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.25 test/models/workarea/pricing/price_test.rb
workarea-core-3.4.24 test/models/workarea/pricing/price_test.rb
workarea-core-3.4.23 test/models/workarea/pricing/price_test.rb
workarea-core-3.4.22 test/models/workarea/pricing/price_test.rb
workarea-core-3.4.21 test/models/workarea/pricing/price_test.rb
workarea-core-3.4.20 test/models/workarea/pricing/price_test.rb
workarea-core-3.4.19 test/models/workarea/pricing/price_test.rb
workarea-core-3.4.18 test/models/workarea/pricing/price_test.rb
workarea-core-3.4.17 test/models/workarea/pricing/price_test.rb
workarea-core-3.4.16 test/models/workarea/pricing/price_test.rb
workarea-core-3.4.15 test/models/workarea/pricing/price_test.rb
workarea-core-3.4.14 test/models/workarea/pricing/price_test.rb
workarea-core-3.4.13 test/models/workarea/pricing/price_test.rb
workarea-core-3.4.12 test/models/workarea/pricing/price_test.rb