Use Faker::UniquenessGenerator to stop name clashes in tests

This commit is contained in:
James Smith committed 2026-06-24 12:31:01 +01:00
1 parent 5787265ce7
commit 3fcf9cedd8
9 files changed
+14 -9

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
FactoryBot.define do
factory :collection do
name { Faker::Name.name }
name { Faker::Name.unique.name }
caption { Faker::Lorem.sentence }
notes { Faker::Lorem.paragraph }
links_attributes { [{url: "http://example.com", text: "anchor text"}] }
+1 -1
View File
@@ -1,6 +1,6 @@
FactoryBot.define do
factory :oauth_application, class: "Doorkeeper::Application" do
name { Faker::Appliance.equipment }
name { Faker::Appliance.unique.equipment }
redirect_uri { "urn:ietf:wg:oauth:2.0:oob" }
scopes { ["read", "write", "delete"] }
confidential { true }
+1 -1
View File
@@ -1,6 +1,6 @@
FactoryBot.define do
factory :actor, class: "Federails::Actor" do
name { Faker::Name.name }
name { Faker::Name.unique.name }
actor_type { "Person" }
entity { nil }
extensions {
+1 -1
View File
@@ -1,6 +1,6 @@
FactoryBot.define do
factory :group do
name { Faker::Commerce.product_name }
name { Faker::Commerce.unique.product_name }
creator
end
end
+1 -1
View File
@@ -1,6 +1,6 @@
FactoryBot.define do
factory :link do
url { Faker::Internet.url }
url { Faker::Internet.unique.url }
text { Faker::Internet.username }
end
end
+1 -1
View File
@@ -1,5 +1,5 @@
FactoryBot.define do
factory :list do
name { Faker::Name.name }
name { Faker::Name.unique.name }
end
end
+1 -1
View File
@@ -1,7 +1,7 @@
FactoryBot.define do
factory :model_file do
model
filename { Faker::File.file_name(ext: "stl") }
filename { Faker::File.unique.file_name(ext: "stl") }
attachment { filename ? Rack::Test::UploadedFile.new(StringIO.new, original_filename: filename) : nil }
after :create do |file, context|
+2 -2
View File
@@ -1,7 +1,7 @@
FactoryBot.define do
factory :user do
email { Faker::Internet.email }
username { Faker::Internet.username specifier: 8, separators: [] }
email { Faker::Internet.unique.email }
username { Faker::Internet.unique.username specifier: 8, separators: [] }
password { Faker::Internet.password max_length: 32, min_length: 32, mix_case: true, special_characters: true }
factory :admin do
+5
View File
@@ -0,0 +1,5 @@
RSpec.configure do |config|
config.after do
Faker::UniqueGenerator.clear
end
end