Sha256: 68c22539a7150e252a810f08ec4b0384e0af1b6f240e4791ff951c08acfb902e

Contents?: true

Size: 1.02 KB

Versions: 62

Compression:

Stored size: 1.02 KB

Contents

require 'test_helper'

module Workarea
  class DiscountIdsTest < TestCase
    class DiscountIdsModel
      include Mongoid::Document
      include DiscountIds

      embeds_many :price_adjustments,
        class_name: 'Workarea::PriceAdjustment',
        extend: PriceAdjustmentExtension
    end

    def discount_price_adjustments
      @discount_price_adjustments ||= [
        PriceAdjustment.new(data: { 'discount_id' => 1 }),
        PriceAdjustment.new(data: { 'discount_id' => 2 }),
        PriceAdjustment.new(data: { 'discount_id' => 3 })
      ]
    end

    def test_save
      discount_ids_model = DiscountIdsModel.new
      discount_ids_model.price_adjustments = discount_price_adjustments
      discount_ids_model.save!
      assert_equal([1, 2, 3], discount_ids_model.as_document['discount_ids'])
    end

    def test_discount_ids
      discount_ids_model = DiscountIdsModel.new
      discount_ids_model.price_adjustments = discount_price_adjustments
      assert_equal([1, 2, 3], discount_ids_model.discount_ids)
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-core-3.5.27 test/models/workarea/discount_ids_test.rb
workarea-core-3.5.26 test/models/workarea/discount_ids_test.rb
workarea-core-3.4.45 test/models/workarea/discount_ids_test.rb
workarea-core-3.5.25 test/models/workarea/discount_ids_test.rb
workarea-core-3.5.23 test/models/workarea/discount_ids_test.rb
workarea-core-3.4.44 test/models/workarea/discount_ids_test.rb
workarea-core-3.5.22 test/models/workarea/discount_ids_test.rb
workarea-core-3.4.43 test/models/workarea/discount_ids_test.rb
workarea-core-3.5.21 test/models/workarea/discount_ids_test.rb
workarea-core-3.4.42 test/models/workarea/discount_ids_test.rb
workarea-core-3.5.20 test/models/workarea/discount_ids_test.rb
workarea-core-3.4.41 test/models/workarea/discount_ids_test.rb
workarea-core-3.5.19 test/models/workarea/discount_ids_test.rb
workarea-core-3.4.40 test/models/workarea/discount_ids_test.rb
workarea-core-3.5.18 test/models/workarea/discount_ids_test.rb
workarea-core-3.4.39 test/models/workarea/discount_ids_test.rb
workarea-core-3.5.17 test/models/workarea/discount_ids_test.rb
workarea-core-3.4.38 test/models/workarea/discount_ids_test.rb
workarea-core-3.5.16 test/models/workarea/discount_ids_test.rb
workarea-core-3.4.37 test/models/workarea/discount_ids_test.rb