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-2.10.5 lib/spree/testing_support/factories/state_factory.rb
solidus_core-2.11.3 lib/spree/testing_support/factories/state_factory.rb
solidus_core-2.11.2 lib/spree/testing_support/factories/state_factory.rb
solidus_core-2.11.1 lib/spree/testing_support/factories/state_factory.rb
solidus_core-2.10.3 lib/spree/testing_support/factories/state_factory.rb
solidus_core-2.11.0 lib/spree/testing_support/factories/state_factory.rb
solidus_core-2.10.2 lib/spree/testing_support/factories/state_factory.rb
solidus_core-2.9.6 lib/spree/testing_support/factories/state_factory.rb
solidus_core-2.8.6 lib/spree/testing_support/factories/state_factory.rb
solidus_core-2.10.1 lib/spree/testing_support/factories/state_factory.rb
solidus_core-2.9.5 lib/spree/testing_support/factories/state_factory.rb
solidus_core-2.10.0 lib/spree/testing_support/factories/state_factory.rb
solidus_core-2.9.4 lib/spree/testing_support/factories/state_factory.rb
solidus_core-2.6.6 lib/spree/testing_support/factories/state_factory.rb
solidus_core-2.7.4 lib/spree/testing_support/factories/state_factory.rb
solidus_core-2.8.5 lib/spree/testing_support/factories/state_factory.rb
solidus_core-2.9.3 lib/spree/testing_support/factories/state_factory.rb
solidus_core-2.9.2 lib/spree/testing_support/factories/state_factory.rb
solidus_core-2.10.0.beta1 lib/spree/testing_support/factories/state_factory.rb
solidus_core-2.7.3 lib/spree/testing_support/factories/state_factory.rb