Sha256: 499af25d6f029818b0573bcaa4ef09cdb5c99bd1f3668d898dac663172265ec0

Contents?: true

Size: 1.64 KB

Versions: 3

Compression:

Stored size: 1.64 KB

Contents

require 'test_helper'

module DiscoApp
  class SynchroniseResourcesServiceTest < ActiveSupport::TestCase

    include ActiveJob::TestHelper

    def setup
      @shop = disco_app_shops(:widget_store)
    end

    def teardown
      @shop = nil
    end

    test 'synchronising all Products' do
      assert_difference 'Product.count', 4 do
        VCR.use_cassette('synchronise_products') do
          DiscoApp::SynchroniseResourcesService.synchronise_all(@shop, 'Product', {})
        end
      end
    end

    test 'synchronising all Products from since_id' do
      assert_difference 'Product.count', 2 do
        VCR.use_cassette('synchronise_products_since_id') do
          DiscoApp::SynchroniseResourcesService.synchronise_all(@shop, 'Product', {}, 95476870)
        end
      end
    end

    test 'synchronising all Products with params' do
      assert_difference 'Product.count', 4 do
        VCR.use_cassette('synchronise_products_with_params') do
          params = { status: :any, product_type: :fruit }

          DiscoApp::SynchroniseResourcesService.synchronise_all(@shop, 'Product', params)
        end
      end
    end
      
    test 'synchronising all Products with pagination enques job with since id' do
      assert_difference 'Product.count', 2 do
        VCR.use_cassette('synchronise_products_paginated') do
          DiscoApp::SynchroniseResourcesService.stub_const(:PAGE_LIMIT, 2) do
            DiscoApp::SynchroniseResourcesService.synchronise_all(@shop, 'Product', {})
          end
        end
      end

      assert_enqueued_with(
        job: DiscoApp::SynchroniseResourcesJob, args: [@shop, 'Product', {}, 5476870]
      )
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
disco_app-0.18.3 test/services/disco_app/synchronise_resources_service_test.rb
disco_app-0.18.6 test/services/disco_app/synchronise_resources_service_test.rb
disco_app-0.18.4 test/services/disco_app/synchronise_resources_service_test.rb