Sha256: f09b642edc9d4cc43f6b0717c7806e958b0d0a5ebf147c96252e68e6c08adbf2

Contents?: true

Size: 1020 Bytes

Versions: 2

Compression:

Stored size: 1020 Bytes

Contents

require 'test_helper'

module Workarea
  class Checkout
    module Steps
      class GiftWrappingShippingTest < TestCase
        def test_update
          order = create_order(items: [])
          order.add_item(
            product_id: '1234',
            sku: 'SKU',
            quantity: 2,
            product_attributes: { allow_gift_wrapping: true }
          )

          checkout = Checkout.new(order)
          step = Steps::Shipping.new(checkout)

          gift_wrap = create_gift_wrap(name: 'Simple', sku: 'GW01')

          step.update(
            gift_message: 'Foo bar',
            gift_wrapping: {
              order.items.first.id.to_s => { gift_wrap: gift_wrap.id.to_s }
            }
          )

          assert_equal('Foo bar', checkout.shipping.reload.gift_message)

          item = order.reload.items.first
          assert_equal({ 'GW01' => 2 }, item.gift_wrap_quantities)
          assert_equal(gift_wrap.id, item.gift_wraps_attributes.first['_id'])
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
workarea-gift_wrapping-1.3.0 test/models/workarea/checkout/steps/gift_wrapping_shipping_test.rb
workarea-gift_wrapping-1.2.1 test/models/workarea/checkout/steps/gift_wrapping_shipping_test.rb