Sha256: 453a57fdfc9bc30b389efde205980903603e551151c8ebaee969fb69cb83714c

Contents?: true

Size: 1.7 KB

Versions: 62

Compression:

Stored size: 1.7 KB

Contents

require 'test_helper'

module Workarea
  class Shipping
    class LocationQueryTest < TestCase
      def test_location_services
        pa_service = create_shipping_service(country: 'US', regions: ['PA'])
        generic = create_shipping_service
        methods = [pa_service, generic]


        location_services = Workarea::Shipping::LocationQuery.new(
          methods,
          Country['US'],
          'PA'
        ).location_services

        refute_includes(location_services.map(&:id), generic.id)
        assert_includes(location_services.map(&:id), pa_service.id)

        location_services = Workarea::Shipping::LocationQuery.new(
          methods,
          Country['US'],
          'CA'
        ).location_services

        assert_includes(location_services.map(&:id), generic.id)
        refute_includes(location_services.map(&:id), pa_service.id)
      end

      def test_initialize_with_different_country_types
        pa_service = create_shipping_service(country: 'US', regions: ['PA'])
        ca_service = create_shipping_service(country: 'US', regions: ['CA'])
        services = [pa_service, ca_service]

        as_string = Workarea::Shipping::LocationQuery.new(
          services,
          'US',
          'PA'
        ).country

        as_country = Workarea::Shipping::LocationQuery.new(
          services,
          Country['US'],
          'PA'
        ).country

        as_active_utils = Workarea::Shipping::LocationQuery.new(
          services,
          ActiveUtils::Country.find('US'),
          'PA'
        ).country

        assert_equal(Country['US'], as_string)
        assert_equal(Country['US'], as_country)
        assert_equal(Country['US'], as_active_utils)
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-core-3.5.27 test/models/workarea/shipping/location_query_test.rb
workarea-core-3.5.26 test/models/workarea/shipping/location_query_test.rb
workarea-core-3.4.45 test/models/workarea/shipping/location_query_test.rb
workarea-core-3.5.25 test/models/workarea/shipping/location_query_test.rb
workarea-core-3.5.23 test/models/workarea/shipping/location_query_test.rb
workarea-core-3.4.44 test/models/workarea/shipping/location_query_test.rb
workarea-core-3.5.22 test/models/workarea/shipping/location_query_test.rb
workarea-core-3.4.43 test/models/workarea/shipping/location_query_test.rb
workarea-core-3.5.21 test/models/workarea/shipping/location_query_test.rb
workarea-core-3.4.42 test/models/workarea/shipping/location_query_test.rb
workarea-core-3.5.20 test/models/workarea/shipping/location_query_test.rb
workarea-core-3.4.41 test/models/workarea/shipping/location_query_test.rb
workarea-core-3.5.19 test/models/workarea/shipping/location_query_test.rb
workarea-core-3.4.40 test/models/workarea/shipping/location_query_test.rb
workarea-core-3.5.18 test/models/workarea/shipping/location_query_test.rb
workarea-core-3.4.39 test/models/workarea/shipping/location_query_test.rb
workarea-core-3.5.17 test/models/workarea/shipping/location_query_test.rb
workarea-core-3.4.38 test/models/workarea/shipping/location_query_test.rb
workarea-core-3.5.16 test/models/workarea/shipping/location_query_test.rb
workarea-core-3.4.37 test/models/workarea/shipping/location_query_test.rb