mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Extract users factories to separate file
This commit is contained in:
@@ -178,34 +178,6 @@ FactoryBot.modify do
|
||||
# Prevent inconsistent ordering in specs when all option types have the same (0) position
|
||||
sequence(:position)
|
||||
end
|
||||
|
||||
factory :user do
|
||||
confirmation_sent_at '1970-01-01 00:00:00'
|
||||
confirmed_at '1970-01-01 00:00:01'
|
||||
|
||||
before(:create) do |user, evaluator|
|
||||
if evaluator.confirmation_sent_at
|
||||
if evaluator.confirmed_at
|
||||
user.skip_confirmation!
|
||||
else
|
||||
user.skip_confirmation_notification!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
after(:create) do |user|
|
||||
user.spree_roles.clear # Remove admin role
|
||||
end
|
||||
end
|
||||
|
||||
factory :admin_user do
|
||||
confirmation_sent_at '1970-01-01 00:00:00'
|
||||
confirmed_at '1970-01-01 00:00:01'
|
||||
|
||||
after(:create) do |user|
|
||||
user.spree_roles << Spree::Role.find_or_create_by_name!('admin')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
FactoryBot.modify do
|
||||
|
||||
29
spec/factories/user_factory.rb
Normal file
29
spec/factories/user_factory.rb
Normal file
@@ -0,0 +1,29 @@
|
||||
FactoryBot.modify do
|
||||
factory :user do
|
||||
confirmation_sent_at '1970-01-01 00:00:00'
|
||||
confirmed_at '1970-01-01 00:00:01'
|
||||
|
||||
before(:create) do |user, evaluator|
|
||||
if evaluator.confirmation_sent_at
|
||||
if evaluator.confirmed_at
|
||||
user.skip_confirmation!
|
||||
else
|
||||
user.skip_confirmation_notification!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
after(:create) do |user|
|
||||
user.spree_roles.clear # Remove admin role
|
||||
end
|
||||
end
|
||||
|
||||
factory :admin_user do
|
||||
confirmation_sent_at '1970-01-01 00:00:00'
|
||||
confirmed_at '1970-01-01 00:00:01'
|
||||
|
||||
after(:create) do |user|
|
||||
user.spree_roles << Spree::Role.find_or_create_by_name!('admin')
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user