Sha256: 8b3efa15e65e6df8c0c6a946037559041715dc8ed085e0f1656b3fdae410c367

Contents?: true

Size: 861 Bytes

Versions: 1

Compression:

Stored size: 861 Bytes

Contents

require 'carmen'
require 'spree/testing_support/factories/country_factory'

FactoryGirl.define do
  # The state factory was changed too drastically in 1.3 to shim
  # we will need to bring this in until we no longer care about old Solidus
  factory :state_with_autodiscover, class: Spree::State do
    transient do
      country_iso 'US'
      state_code 'AL'

      carmen_subregion do
        carmen_country = Carmen::Country.coded(country.iso)
        carmen_country.subregions.coded(state_code) ||
          carmen_country.subregions.sort_by(&:name).first ||
          fail("Country #{country.iso} has no subregions")
      end
    end

    abbr { carmen_subregion.code }
    name { carmen_subregion.name }

    country do |country|
      Spree::Country.find_by(iso: country_iso) ||
        country.association(:country, iso: country_iso)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
solidus_active_shipping-1.0.0 spec/factories/state_factory_override.rb