Sha256: e80af6a5a42a6fa12350e6efe8d8e0d0596093b2e8eee098cb2ab65217a42a36

Contents?: true

Size: 726 Bytes

Versions: 48

Compression:

Stored size: 726 Bytes

Contents

# frozen_string_literal: true

require 'spree/testing_support/factories/country_factory'

FactoryBot.define do
  factory :state, 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

48 entries across 48 versions & 2 rubygems

Version Path
solidus_core_devise_token_auth-2.8.0.alpha.7 lib/spree/testing_support/factories/state_factory.rb
solidus_core_devise_token_auth-2.8.0.alpha.6 lib/spree/testing_support/factories/state_factory.rb
solidus_core_devise_token_auth-2.8.0.alpha.5 lib/spree/testing_support/factories/state_factory.rb
solidus_core_devise_token_auth-2.8.0.alpha.4 lib/spree/testing_support/factories/state_factory.rb
solidus_core_devise_token_auth-2.8.0.alpha.3 lib/spree/testing_support/factories/state_factory.rb
solidus_core_devise_token_auth-2.8.0.alpha.1 lib/spree/testing_support/factories/state_factory.rb
solidus_core_devise_token_auth-2.8.0.alpha.0 lib/spree/testing_support/factories/state_factory.rb
solidus_core-2.7.0 lib/spree/testing_support/factories/state_factory.rb