Sha256: 86f2bcca542f13351c0fb35fd44069b3ffb5bb4d22c7f30489b62c32011bc93f

Contents?: true

Size: 738 Bytes

Versions: 21

Compression:

Stored size: 738 Bytes

Contents

# frozen_string_literal: true

FactoryBot.define do
  factory :user, class: Spree::UserClassHandle.new do
    email { generate(:email) }
    password { 'secret' }
    password_confirmation { password }

    trait :with_api_key do
      after(:create) do |user, _|
        user.generate_spree_api_key!
      end
    end

    trait :with_orders do
      after(:create) do |user, _|
        create(:order, user: user)
      end
    end

    factory :admin_user do
      after(:create) do |user, _|
        admin_role = Spree::Role.find_by(name: 'admin') || create(:role, name: 'admin')
        user.spree_roles << admin_role
      end
    end

    factory :user_with_addresses do |_u|
      bill_address
      ship_address
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
solidus_core-4.3.4 lib/spree/testing_support/factories/user_factory.rb
solidus_core-4.2.4 lib/spree/testing_support/factories/user_factory.rb
solidus_core-4.1.5 lib/spree/testing_support/factories/user_factory.rb
solidus_core-4.3.3 lib/spree/testing_support/factories/user_factory.rb
solidus_core-4.3.2 lib/spree/testing_support/factories/user_factory.rb
solidus_core-4.1.4 lib/spree/testing_support/factories/user_factory.rb
solidus_core-4.3.1 lib/spree/testing_support/factories/user_factory.rb
solidus_core-4.3.0 lib/spree/testing_support/factories/user_factory.rb
solidus_core-4.2.3 lib/spree/testing_support/factories/user_factory.rb
solidus_core-4.1.3 lib/spree/testing_support/factories/user_factory.rb
solidus_core-4.0.4 lib/spree/testing_support/factories/user_factory.rb
solidus_core-4.0.3 lib/spree/testing_support/factories/user_factory.rb
solidus_core-4.1.2 lib/spree/testing_support/factories/user_factory.rb
solidus_core-4.2.2 lib/spree/testing_support/factories/user_factory.rb
solidus_core-4.2.1 lib/spree/testing_support/factories/user_factory.rb
solidus_core-4.2.0 lib/spree/testing_support/factories/user_factory.rb
solidus_core-4.1.1 lib/spree/testing_support/factories/user_factory.rb
solidus_core-4.0.2 lib/spree/testing_support/factories/user_factory.rb
solidus_core-4.0.1 lib/spree/testing_support/factories/user_factory.rb
solidus_core-4.1.0 lib/spree/testing_support/factories/user_factory.rb