Sha256: c645a9593e154a2dc1444503af7eaa87ec7e68b0174c7a2d12ca77949841ccf5

Contents?: true

Size: 1.12 KB

Versions: 28

Compression:

Stored size: 1.12 KB

Contents

require 'test_helper'

module Workarea
  class Fulfillment
    module Policies
      class DownloadTest < TestCase
        def test_process
          order = Order.new(user_id: '1234')
          item = order.items.build(sku: 'SKU1')

          fulfillment = Fulfillment.new(
            id: order.id,
            items: [{ order_item_id: item.id.to_s, quantity: 1 }]
          )

          sku = create_fulfillment_sku(
            id: 'SKU1',
            policy: 'download',
            file: product_image_file
          )

          policy = Policies::Download.new(sku)
          policy.process(order_item: item, fulfillment: fulfillment)

          assert_equal(1, Fulfillment::Token.count)

          token = Fulfillment::Token.first
          assert_equal(order.id.to_s, token.order_id)
          assert_equal(item.id.to_s, token.order_item_id)
          assert_equal(sku.id, token.sku)

          assert_equal(1, fulfillment.items.first.events.size)
          assert_equal('shipped', fulfillment.items.first.events.first.status)
          assert_equal(1, fulfillment.items.first.events.first.quantity)
        end
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
workarea-core-3.5.27 test/models/workarea/fulfillment/policies/download_test.rb
workarea-core-3.5.26 test/models/workarea/fulfillment/policies/download_test.rb
workarea-core-3.5.25 test/models/workarea/fulfillment/policies/download_test.rb
workarea-core-3.5.23 test/models/workarea/fulfillment/policies/download_test.rb
workarea-core-3.5.22 test/models/workarea/fulfillment/policies/download_test.rb
workarea-core-3.5.21 test/models/workarea/fulfillment/policies/download_test.rb
workarea-core-3.5.20 test/models/workarea/fulfillment/policies/download_test.rb
workarea-core-3.5.19 test/models/workarea/fulfillment/policies/download_test.rb
workarea-core-3.5.18 test/models/workarea/fulfillment/policies/download_test.rb
workarea-core-3.5.17 test/models/workarea/fulfillment/policies/download_test.rb
workarea-core-3.5.16 test/models/workarea/fulfillment/policies/download_test.rb
workarea-core-3.5.15 test/models/workarea/fulfillment/policies/download_test.rb
workarea-core-3.5.14 test/models/workarea/fulfillment/policies/download_test.rb
workarea-core-3.5.13 test/models/workarea/fulfillment/policies/download_test.rb
workarea-core-3.5.12 test/models/workarea/fulfillment/policies/download_test.rb
workarea-core-3.5.11 test/models/workarea/fulfillment/policies/download_test.rb
workarea-core-3.5.10 test/models/workarea/fulfillment/policies/download_test.rb
workarea-core-3.5.9 test/models/workarea/fulfillment/policies/download_test.rb
workarea-core-3.5.8 test/models/workarea/fulfillment/policies/download_test.rb
workarea-core-3.5.7 test/models/workarea/fulfillment/policies/download_test.rb