From 98ef38e34ebc7f296a818e8cb454219f997529c2 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Mon, 11 Mar 2024 04:53:24 -0400 Subject: [PATCH] Ensure unique values in fabricators (#29515) --- spec/fabrication/fabricators_spec.rb | 6 +++--- spec/fabricators/identity_fabricator.rb | 2 +- spec/fabricators/relay_fabricator.rb | 2 +- spec/fabricators/site_upload_fabricator.rb | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/fabrication/fabricators_spec.rb b/spec/fabrication/fabricators_spec.rb index 53193378c..2cf45041a 100644 --- a/spec/fabrication/fabricators_spec.rb +++ b/spec/fabrication/fabricators_spec.rb @@ -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 diff --git a/spec/fabricators/identity_fabricator.rb b/spec/fabricators/identity_fabricator.rb index 83655ee83..6e125a4e7 100644 --- a/spec/fabricators/identity_fabricator.rb +++ b/spec/fabricators/identity_fabricator.rb @@ -3,5 +3,5 @@ Fabricator(:identity) do user { Fabricate.build(:user) } provider 'MyString' - uid 'MyString' + uid { sequence(:uid) { |i| "uid_string_#{i}" } } end diff --git a/spec/fabricators/relay_fabricator.rb b/spec/fabricators/relay_fabricator.rb index ad8ba86fc..07fc6f88c 100644 --- a/spec/fabricators/relay_fabricator.rb +++ b/spec/fabricators/relay_fabricator.rb @@ -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 diff --git a/spec/fabricators/site_upload_fabricator.rb b/spec/fabricators/site_upload_fabricator.rb index 87553ccb8..cbe42d3b4 100644 --- a/spec/fabricators/site_upload_fabricator.rb +++ b/spec/fabricators/site_upload_fabricator.rb @@ -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