Sha256: 34e0c2ea01ca0a4e0b7b1d245c4425f4a80dea0d4981f8f9437e7948e289a859

Contents?: true

Size: 1.58 KB

Versions: 4

Compression:

Stored size: 1.58 KB

Contents

require 'test_helper'

module Workarea
  module Api
    module Admin
      class OrdersIntegrationTest < IntegrationTest
        include Workarea::Admin::IntegrationTest

        def test_lists_orders
          orders = [create_order, create_order]
          get admin_api.orders_path
          result = JSON.parse(response.body)['orders']

          assert_equal(2, result.length)
          assert_equal(orders.second, Order.new(result.first))
          assert_equal(orders.first, Order.new(result.second))
        end

        def test_filters_orders
          orders = [
            create_order(placed_at: 1.week.ago),
            create_order(placed_at: 2.days.ago)
          ]

          get admin_api.orders_path(
            placed_at_greater_than: 3.days.ago,
            placed_at_less_than: 1.days.ago
          )

          result = JSON.parse(response.body)['orders']

          assert_equal(1, result.length)
          assert_equal(orders.second, Order.new(result.first))
        end

        def test_shows_orders
          order = create_placed_order
          payment = Payment.find(order.id)
          fulfillment = Fulfillment.find(order.id)
          shipping = Shipping.find_by_order(order.id)

          get admin_api.order_path(order.id)
          result = JSON.parse(response.body)

          assert_equal(order, Order.new(result['order']))
          assert_equal(payment, Payment.new(result['payment']))
          assert_equal(fulfillment, Fulfillment.new(result['fulfillment']))
          assert_equal(shipping, Shipping.new(result['shippings'].first))
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
workarea-api-4.4.7 admin/test/integration/workarea/api/admin/orders_integration_test.rb
workarea-api-admin-4.4.7 test/integration/workarea/api/admin/orders_integration_test.rb
workarea-api-4.4.6 admin/test/integration/workarea/api/admin/orders_integration_test.rb
workarea-api-admin-4.4.6 test/integration/workarea/api/admin/orders_integration_test.rb