Sha256: 4b2ababb136eadd3cee857c9af0dcacee8f3f888cf81d11fc6e0e3799af491dc

Contents?: true

Size: 1.14 KB

Versions: 3

Compression:

Stored size: 1.14 KB

Contents

require 'test_helper'

module Workarea
  class Emarsys::SyncOrdersTest < TestCase
    include EmarsysApiConfig

    def test_sync_orders_sends_file
      VCR.use_cassette("emarsys/sales/send_data", match_requests_on: [:method, :uri]) do
        Workarea.with_config do |config|
          merchant_id = Workarea::Emarsys::Configuration.create!(merchant_id: "19CAA097101B372A").merchant_id

          api_url = "https://admin.scarabresearch.com/hapi/merchant/#{merchant_id}/sales-data/api"

          config.emarsys.merchant_id = merchant_id

          create_placed_order

          Workarea::Emarsys::SyncOrders.new.perform

          assert_requested :post, api_url
        end
      end
    end

    def test_sync_orders_sends_nothing_when_no_orders
      Workarea.with_config do |config|
        merchant_id = Workarea::Emarsys::Configuration.create!(merchant_id: "19CAA097101B372A").merchant_id
        api_url = "https://admin.scarabresearch.com/hapi/merchant/#{merchant_id}/sales-data/api"

        config.emarsys.merchant_id = merchant_id

        Workarea::Emarsys::SyncOrders.new.perform

        refute_requested :post, api_url
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
workarea-emarsys-1.0.4 test/workers/workarea/emarsys/sync_orders_test.rb
workarea-emarsys-1.0.3 test/workers/workarea/emarsys/sync_orders_test.rb
workarea-emarsys-1.0.2 test/workers/workarea/emarsys/sync_orders_test.rb