Ensure unique values in fabricators (#29515)

shrike
Matt Jankowski 2024-03-11 04:53:24 -04:00 committed by GitHub
parent 6f8ec6d7f8
commit 98ef38e34e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 6 additions and 6 deletions

View File

@ -6,9 +6,9 @@ Fabrication.manager.load_definitions if Fabrication.manager.empty?
Fabrication.manager.schematics.map(&:first).each do |factory_name|
describe "The #{factory_name} factory" do
it 'is valid' do
factory = Fabricate(factory_name)
expect(factory).to be_valid
it 'is able to create valid records' do
records = Fabricate.times(2, factory_name) # Create multiple of each to uncover uniqueness issues
expect(records).to all(be_valid)
end
end
end

View File

@ -3,5 +3,5 @@
Fabricator(:identity) do
user { Fabricate.build(:user) }
provider 'MyString'
uid 'MyString'
uid { sequence(:uid) { |i| "uid_string_#{i}" } }
end

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true
Fabricator(:relay) do
inbox_url 'https://example.com/inbox'
inbox_url { sequence(:inbox_url) { |i| "https://example.com/inboxes/#{i}" } }
state :idle
end

View File

@ -2,5 +2,5 @@
Fabricator(:site_upload) do
file { Rails.root.join('spec', 'fabricators', 'assets', 'utah_teapot.png').open }
var 'thumbnail'
var { sequence(:var) { |i| "thumbnail_#{i}" } }
end