Sha256: 7dd0c2ae757be9cc8c93d7e185646bdb23499e7bdd8e3c19c25a0924836062c5

Contents?: true

Size: 1 KB

Versions: 20

Compression:

Stored size: 1 KB

Contents

require 'spree/testing_support/sequences'
require 'spree/testing_support/factories/role_factory'
require 'spree/testing_support/factories/address_factory'

FactoryGirl.define do
  sequence :user_authentication_token do |n|
    "xxxx#{Time.current.to_i}#{rand(1000)}#{n}xxxxxxxxxxxxx"
  end

  factory :user, class: Spree.user_class do
    email { generate(:random_email) }
    login { email } if Spree.user_class.attribute_method? :login
    password 'secret'
    password_confirmation { password } if Spree.user_class.attribute_method? :password_confirmation
    authentication_token { generate(:user_authentication_token) } if Spree.user_class.attribute_method? :authentication_token

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

    factory :admin_user do
      spree_roles { [Spree::Role.find_by(name: 'admin') || create(:role, name: 'admin')] }
    end

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

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
solidus_core-2.4.2 lib/spree/testing_support/factories/user_factory.rb
solidus_core-2.3.1 lib/spree/testing_support/factories/user_factory.rb
solidus_core-2.4.1 lib/spree/testing_support/factories/user_factory.rb
solidus_core-2.2.2 lib/spree/testing_support/factories/user_factory.rb
solidus_core-2.1.1 lib/spree/testing_support/factories/user_factory.rb
solidus_core-2.4.0 lib/spree/testing_support/factories/user_factory.rb
solidus_core-2.4.0.rc1 lib/spree/testing_support/factories/user_factory.rb
solidus_core-2.4.0.beta1 lib/spree/testing_support/factories/user_factory.rb
solidus_core-2.3.0 lib/spree/testing_support/factories/user_factory.rb
solidus_core-2.3.0.rc3 lib/spree/testing_support/factories/user_factory.rb
solidus_core-2.3.0.rc2 lib/spree/testing_support/factories/user_factory.rb
solidus_core-2.3.0.rc1 lib/spree/testing_support/factories/user_factory.rb
solidus_core-2.3.0.beta1 lib/spree/testing_support/factories/user_factory.rb
solidus_core-2.2.1 lib/spree/testing_support/factories/user_factory.rb
solidus_core-2.2.0 lib/spree/testing_support/factories/user_factory.rb
solidus_core-2.2.0.rc1 lib/spree/testing_support/factories/user_factory.rb
solidus_core-2.2.0.beta1 lib/spree/testing_support/factories/user_factory.rb
solidus_core-2.1.0 lib/spree/testing_support/factories/user_factory.rb
solidus_core-2.1.0.rc1 lib/spree/testing_support/factories/user_factory.rb
solidus_core-2.1.0.beta1 lib/spree/testing_support/factories/user_factory.rb