Sha256: 45972e0291a64e7fdee213f94868280dbb5c959c76e2454128e75a04ebda991b

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

require 'test_helper'

module Workarea
  module FlowIo
    class OrderPutFormTest < Workarea::TestCase
      include FlowFixtures

      setup :setup_pricing_skus

      def setup_pricing_skus
        %w(sku1 sku2 sku3).each do |sku|
          create_pricing_sku(id: sku)
        end
      end

      def test_to_flow_model
        Pricing.perform(order)

        order_put_form = OrderPutForm.from(order: order)
        line_item_form = order_put_form.items.first

        assert_equal(order_put_form.customer.name.first, user.first_name)
        assert_equal(order_put_form.customer.name.last, user.last_name)
        assert_equal(11000, line_item_form.price.amount)
        assert_equal('CAD', line_item_form.price.currency)
      end

      private

        def user
          @user ||= create_user
        end

        def order
          @order ||= create_order(
            id: "1234",
            user_id: user.id,
            experience: build_flow_io_experience_geo,
            items: [
              { quantity: 1, sku: "sku1", product_id: "PRODUCT1" },
              { quantity: 2, sku: "sku2", product_id: "PRODUCT1" },
              { quantity: 2, sku: "sku3", product_id: "PRODUCT2" }
            ]
          )
        end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
workarea-flow_io-1.2.1 test/services/workarea/flow_io/order_put_form_test.rb