Generate truly random email addresses in factory
Previously, it could happen under some (random) circumstances that a series of users got the same user name. This is caused by the usage of Forgery for generating a name. Forgery itself picks a random name from a list, and there is no check that two calls would indeed deliver two different names. In order to solve the issue, we generate a truly unique email address for specs, so that the problem won't arise again.
This commit is contained in:
@ -8,7 +8,7 @@ FactoryBot.define do
|
||||
end
|
||||
|
||||
trait :generated_email do
|
||||
email { "#{name.underscore.tr(' ', '.')}@example.org" }
|
||||
sequence(:email) {|n| "#{name.underscore.tr(' ', '.')}.#{n}@example.org" }
|
||||
end
|
||||
|
||||
trait :generated_user_name do
|
||||
|
Reference in New Issue
Block a user