From 3a2a15c6ea4d4603469861ed9be09da12a122e45 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Sat, 10 Jun 2023 12:29:01 -0400 Subject: [PATCH] Use `build` where possible in fabricators (#25360) --- spec/fabricators/account_domain_block_fabricator.rb | 2 +- spec/fabricators/account_moderation_note_fabricator.rb | 4 ++-- spec/fabricators/account_note_fabricator.rb | 4 ++-- spec/fabricators/account_stat_fabricator.rb | 2 +- .../fabricators/account_statuses_cleanup_policy_fabricator.rb | 2 +- spec/fabricators/account_warning_fabricator.rb | 2 +- spec/fabricators/admin_action_log_fabricator.rb | 2 +- spec/fabricators/backup_fabricator.rb | 2 +- spec/fabricators/block_fabricator.rb | 4 ++-- spec/fabricators/bookmark_fabricator.rb | 4 ++-- spec/fabricators/bulk_import_fabricator.rb | 2 +- spec/fabricators/bulk_import_row_fabricator.rb | 2 +- spec/fabricators/canonical_email_block_fabricator.rb | 2 +- spec/fabricators/custom_filter_fabricator.rb | 2 +- spec/fabricators/custom_filter_keyword_fabricator.rb | 2 +- spec/fabricators/custom_filter_status_fabricator.rb | 4 ++-- spec/fabricators/device_fabricator.rb | 4 ++-- spec/fabricators/encrypted_message_fabricator.rb | 4 ++-- spec/fabricators/favourite_fabricator.rb | 4 ++-- spec/fabricators/featured_tag_fabricator.rb | 4 ++-- spec/fabricators/follow_fabricator.rb | 4 ++-- spec/fabricators/follow_request_fabricator.rb | 4 ++-- spec/fabricators/identity_fabricator.rb | 2 +- spec/fabricators/invite_fabricator.rb | 2 +- spec/fabricators/list_fabricator.rb | 2 +- spec/fabricators/login_activity_fabricator.rb | 2 +- spec/fabricators/marker_fabricator.rb | 2 +- spec/fabricators/media_attachment_fabricator.rb | 2 +- spec/fabricators/mention_fabricator.rb | 4 ++-- spec/fabricators/mute_fabricator.rb | 4 ++-- spec/fabricators/notification_fabricator.rb | 2 +- spec/fabricators/one_time_key_fabricator.rb | 2 +- spec/fabricators/poll_fabricator.rb | 4 ++-- spec/fabricators/poll_vote_fabricator.rb | 2 +- spec/fabricators/report_fabricator.rb | 4 ++-- spec/fabricators/report_note_fabricator.rb | 4 ++-- spec/fabricators/scheduled_status_fabricator.rb | 2 +- spec/fabricators/session_activation_fabricator.rb | 2 +- spec/fabricators/status_fabricator.rb | 2 +- spec/fabricators/status_pin_fabricator.rb | 4 ++-- spec/fabricators/tag_follow_fabricator.rb | 2 +- 41 files changed, 58 insertions(+), 58 deletions(-) diff --git a/spec/fabricators/account_domain_block_fabricator.rb b/spec/fabricators/account_domain_block_fabricator.rb index ff85e17f3..83df509da 100644 --- a/spec/fabricators/account_domain_block_fabricator.rb +++ b/spec/fabricators/account_domain_block_fabricator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true Fabricator(:account_domain_block) do - account + account { Fabricate.build(:account) } domain 'example.com' end diff --git a/spec/fabricators/account_moderation_note_fabricator.rb b/spec/fabricators/account_moderation_note_fabricator.rb index 341a24dea..05a687bf4 100644 --- a/spec/fabricators/account_moderation_note_fabricator.rb +++ b/spec/fabricators/account_moderation_note_fabricator.rb @@ -2,6 +2,6 @@ Fabricator(:account_moderation_note) do content 'MyText' - account - target_account { Fabricate(:account) } + account { Fabricate.build(:account) } + target_account { Fabricate.build(:account) } end diff --git a/spec/fabricators/account_note_fabricator.rb b/spec/fabricators/account_note_fabricator.rb index bb4ed8b24..241362c14 100644 --- a/spec/fabricators/account_note_fabricator.rb +++ b/spec/fabricators/account_note_fabricator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Fabricator(:account_note) do - account - target_account { Fabricate(:account) } + account { Fabricate.build(:account) } + target_account { Fabricate.build(:account) } comment 'User note text' end diff --git a/spec/fabricators/account_stat_fabricator.rb b/spec/fabricators/account_stat_fabricator.rb index e6085c5f2..20272fb22 100644 --- a/spec/fabricators/account_stat_fabricator.rb +++ b/spec/fabricators/account_stat_fabricator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Fabricator(:account_stat) do - account + account { Fabricate.build(:account) } statuses_count '123' following_count '456' followers_count '789' diff --git a/spec/fabricators/account_statuses_cleanup_policy_fabricator.rb b/spec/fabricators/account_statuses_cleanup_policy_fabricator.rb index 0e756ddba..fcf7a5347 100644 --- a/spec/fabricators/account_statuses_cleanup_policy_fabricator.rb +++ b/spec/fabricators/account_statuses_cleanup_policy_fabricator.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true Fabricator(:account_statuses_cleanup_policy) do - account + account { Fabricate.build(:account) } end diff --git a/spec/fabricators/account_warning_fabricator.rb b/spec/fabricators/account_warning_fabricator.rb index e5059e37f..70005a927 100644 --- a/spec/fabricators/account_warning_fabricator.rb +++ b/spec/fabricators/account_warning_fabricator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Fabricator(:account_warning) do - account + account { Fabricate.build(:account) } target_account(fabricator: :account) text { Faker::Lorem.paragraph } action 'suspend' diff --git a/spec/fabricators/admin_action_log_fabricator.rb b/spec/fabricators/admin_action_log_fabricator.rb index a259644bd..3acedbffd 100644 --- a/spec/fabricators/admin_action_log_fabricator.rb +++ b/spec/fabricators/admin_action_log_fabricator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Fabricator('Admin::ActionLog') do - account + account { Fabricate.build(:account) } action 'MyString' target nil end diff --git a/spec/fabricators/backup_fabricator.rb b/spec/fabricators/backup_fabricator.rb index c73ae54be..58e37c987 100644 --- a/spec/fabricators/backup_fabricator.rb +++ b/spec/fabricators/backup_fabricator.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true Fabricator(:backup) do - user + user { Fabricate.build(:user) } end diff --git a/spec/fabricators/block_fabricator.rb b/spec/fabricators/block_fabricator.rb index c2e9e9628..c4087e46d 100644 --- a/spec/fabricators/block_fabricator.rb +++ b/spec/fabricators/block_fabricator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true Fabricator(:block) do - account - target_account { Fabricate(:account) } + account { Fabricate.build(:account) } + target_account { Fabricate.build(:account) } end diff --git a/spec/fabricators/bookmark_fabricator.rb b/spec/fabricators/bookmark_fabricator.rb index e21046fc2..994ac6e68 100644 --- a/spec/fabricators/bookmark_fabricator.rb +++ b/spec/fabricators/bookmark_fabricator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true Fabricator(:bookmark) do - account - status + account { Fabricate.build(:account) } + status { Fabricate.build(:status) } end diff --git a/spec/fabricators/bulk_import_fabricator.rb b/spec/fabricators/bulk_import_fabricator.rb index 673b7960d..d30758dfe 100644 --- a/spec/fabricators/bulk_import_fabricator.rb +++ b/spec/fabricators/bulk_import_fabricator.rb @@ -8,5 +8,5 @@ Fabricator(:bulk_import) do imported_items 1 finished_at '2022-11-18 14:55:07' overwrite false - account + account { Fabricate.build(:account) } end diff --git a/spec/fabricators/bulk_import_row_fabricator.rb b/spec/fabricators/bulk_import_row_fabricator.rb index f8358e734..10a4bf160 100644 --- a/spec/fabricators/bulk_import_row_fabricator.rb +++ b/spec/fabricators/bulk_import_row_fabricator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true Fabricator(:bulk_import_row) do - bulk_import + bulk_import { Fabricate.build(:bulk_import) } data '' end diff --git a/spec/fabricators/canonical_email_block_fabricator.rb b/spec/fabricators/canonical_email_block_fabricator.rb index 3a018059f..1ef53ff4a 100644 --- a/spec/fabricators/canonical_email_block_fabricator.rb +++ b/spec/fabricators/canonical_email_block_fabricator.rb @@ -2,5 +2,5 @@ Fabricator(:canonical_email_block) do email { sequence(:email) { |i| "#{i}#{Faker::Internet.email}" } } - reference_account { Fabricate(:account) } + reference_account { Fabricate.build(:account) } end diff --git a/spec/fabricators/custom_filter_fabricator.rb b/spec/fabricators/custom_filter_fabricator.rb index 5fee4f01a..766cc3b11 100644 --- a/spec/fabricators/custom_filter_fabricator.rb +++ b/spec/fabricators/custom_filter_fabricator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Fabricator(:custom_filter) do - account + account { Fabricate.build(:account) } expires_at nil phrase 'discourse' context %w(home notifications) diff --git a/spec/fabricators/custom_filter_keyword_fabricator.rb b/spec/fabricators/custom_filter_keyword_fabricator.rb index f1fb440dc..aa4bf8473 100644 --- a/spec/fabricators/custom_filter_keyword_fabricator.rb +++ b/spec/fabricators/custom_filter_keyword_fabricator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true Fabricator(:custom_filter_keyword) do - custom_filter + custom_filter { Fabricate.build(:custom_filter) } keyword 'discourse' end diff --git a/spec/fabricators/custom_filter_status_fabricator.rb b/spec/fabricators/custom_filter_status_fabricator.rb index 3ef1d0ec8..f66f62e56 100644 --- a/spec/fabricators/custom_filter_status_fabricator.rb +++ b/spec/fabricators/custom_filter_status_fabricator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true Fabricator(:custom_filter_status) do - custom_filter - status + custom_filter { Fabricate.build(:custom_filter) } + status { Fabricate.build(:status) } end diff --git a/spec/fabricators/device_fabricator.rb b/spec/fabricators/device_fabricator.rb index 26c71b4fd..37a2e8977 100644 --- a/spec/fabricators/device_fabricator.rb +++ b/spec/fabricators/device_fabricator.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true Fabricator(:device) do - access_token - account + access_token { Fabricate.build(:access_token) } + account { Fabricate.build(:account) } device_id { Faker::Number.number(digits: 5) } name { Faker::App.name } fingerprint_key { Base64.strict_encode64(Ed25519::SigningKey.generate.verify_key.to_bytes) } diff --git a/spec/fabricators/encrypted_message_fabricator.rb b/spec/fabricators/encrypted_message_fabricator.rb index 43b310514..349b659c2 100644 --- a/spec/fabricators/encrypted_message_fabricator.rb +++ b/spec/fabricators/encrypted_message_fabricator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Fabricator(:encrypted_message) do - device - from_account { Fabricate(:account) } + device { Fabricate.build(:device) } + from_account { Fabricate.build(:account) } from_device_id { Faker::Number.number(digits: 5) } end diff --git a/spec/fabricators/favourite_fabricator.rb b/spec/fabricators/favourite_fabricator.rb index 005947e6f..639416987 100644 --- a/spec/fabricators/favourite_fabricator.rb +++ b/spec/fabricators/favourite_fabricator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true Fabricator(:favourite) do - account - status + account { Fabricate.build(:account) } + status { Fabricate.build(:status) } end diff --git a/spec/fabricators/featured_tag_fabricator.rb b/spec/fabricators/featured_tag_fabricator.rb index 838364056..0803dc43a 100644 --- a/spec/fabricators/featured_tag_fabricator.rb +++ b/spec/fabricators/featured_tag_fabricator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Fabricator(:featured_tag) do - account - tag + account { Fabricate.build(:account) } + tag { Fabricate.build(:tag) } name { sequence(:name) { |i| "Tag#{i}" } } end diff --git a/spec/fabricators/follow_fabricator.rb b/spec/fabricators/follow_fabricator.rb index 41b5305d5..29886b430 100644 --- a/spec/fabricators/follow_fabricator.rb +++ b/spec/fabricators/follow_fabricator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true Fabricator(:follow) do - account - target_account { Fabricate(:account) } + account { Fabricate.build(:account) } + target_account { Fabricate.build(:account) } end diff --git a/spec/fabricators/follow_request_fabricator.rb b/spec/fabricators/follow_request_fabricator.rb index 86b82611f..6b2d658a3 100644 --- a/spec/fabricators/follow_request_fabricator.rb +++ b/spec/fabricators/follow_request_fabricator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true Fabricator(:follow_request) do - account - target_account { Fabricate(:account, locked: true) } + account { Fabricate.build(:account) } + target_account { Fabricate.build(:account, locked: true) } end diff --git a/spec/fabricators/identity_fabricator.rb b/spec/fabricators/identity_fabricator.rb index 58072c0d6..83655ee83 100644 --- a/spec/fabricators/identity_fabricator.rb +++ b/spec/fabricators/identity_fabricator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Fabricator(:identity) do - user + user { Fabricate.build(:user) } provider 'MyString' uid 'MyString' end diff --git a/spec/fabricators/invite_fabricator.rb b/spec/fabricators/invite_fabricator.rb index 4f47d6ce2..8fdf5f918 100644 --- a/spec/fabricators/invite_fabricator.rb +++ b/spec/fabricators/invite_fabricator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Fabricator(:invite) do - user + user { Fabricate.build(:user) } expires_at nil max_uses nil uses 0 diff --git a/spec/fabricators/list_fabricator.rb b/spec/fabricators/list_fabricator.rb index 47af752b8..d2bdc1012 100644 --- a/spec/fabricators/list_fabricator.rb +++ b/spec/fabricators/list_fabricator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true Fabricator(:list) do - account + account { Fabricate.build(:account) } title 'MyString' end diff --git a/spec/fabricators/login_activity_fabricator.rb b/spec/fabricators/login_activity_fabricator.rb index 2b30658ff..3309a303d 100644 --- a/spec/fabricators/login_activity_fabricator.rb +++ b/spec/fabricators/login_activity_fabricator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Fabricator(:login_activity) do - user + user { Fabricate.build(:user) } authentication_method 'password' success true failure_reason nil diff --git a/spec/fabricators/marker_fabricator.rb b/spec/fabricators/marker_fabricator.rb index 561c2553a..641db6b9e 100644 --- a/spec/fabricators/marker_fabricator.rb +++ b/spec/fabricators/marker_fabricator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Fabricator(:marker) do - user + user { Fabricate.build(:user) } timeline 'home' last_read_id 0 lock_version 0 diff --git a/spec/fabricators/media_attachment_fabricator.rb b/spec/fabricators/media_attachment_fabricator.rb index 4a081dccb..062d3cbfe 100644 --- a/spec/fabricators/media_attachment_fabricator.rb +++ b/spec/fabricators/media_attachment_fabricator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Fabricator(:media_attachment) do - account + account { Fabricate.build(:account) } file do |attrs| case attrs[:type] diff --git a/spec/fabricators/mention_fabricator.rb b/spec/fabricators/mention_fabricator.rb index 5a8392827..ee8160aeb 100644 --- a/spec/fabricators/mention_fabricator.rb +++ b/spec/fabricators/mention_fabricator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true Fabricator(:mention) do - account - status + account { Fabricate.build(:account) } + status { Fabricate.build(:status) } end diff --git a/spec/fabricators/mute_fabricator.rb b/spec/fabricators/mute_fabricator.rb index 242ae2b08..a70d3ff26 100644 --- a/spec/fabricators/mute_fabricator.rb +++ b/spec/fabricators/mute_fabricator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true Fabricator(:mute) do - account - target_account { Fabricate(:account) } + account { Fabricate.build(:account) } + target_account { Fabricate.build(:account) } end diff --git a/spec/fabricators/notification_fabricator.rb b/spec/fabricators/notification_fabricator.rb index 1e0c80987..fdfd7673e 100644 --- a/spec/fabricators/notification_fabricator.rb +++ b/spec/fabricators/notification_fabricator.rb @@ -2,5 +2,5 @@ Fabricator(:notification) do activity fabricator: :status - account + account { Fabricate.build(:account) } end diff --git a/spec/fabricators/one_time_key_fabricator.rb b/spec/fabricators/one_time_key_fabricator.rb index cfb365cab..505282e05 100644 --- a/spec/fabricators/one_time_key_fabricator.rb +++ b/spec/fabricators/one_time_key_fabricator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Fabricator(:one_time_key) do - device + device { Fabricate.build(:device) } key_id { Faker::Alphanumeric.alphanumeric(number: 10) } key { Base64.strict_encode64(Ed25519::SigningKey.generate.verify_key.to_bytes) } diff --git a/spec/fabricators/poll_fabricator.rb b/spec/fabricators/poll_fabricator.rb index 19c3b1d16..0203609ce 100644 --- a/spec/fabricators/poll_fabricator.rb +++ b/spec/fabricators/poll_fabricator.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true Fabricator(:poll) do - account - status + account { Fabricate.build(:account) } + status { Fabricate.build(:status) } expires_at { 7.days.from_now } options %w(Foo Bar) multiple false diff --git a/spec/fabricators/poll_vote_fabricator.rb b/spec/fabricators/poll_vote_fabricator.rb index 9099ae96f..47813cdb7 100644 --- a/spec/fabricators/poll_vote_fabricator.rb +++ b/spec/fabricators/poll_vote_fabricator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Fabricator(:poll_vote) do - account + account { Fabricate.build(:account) } poll choice 0 end diff --git a/spec/fabricators/report_fabricator.rb b/spec/fabricators/report_fabricator.rb index 7124773ad..ed890230a 100644 --- a/spec/fabricators/report_fabricator.rb +++ b/spec/fabricators/report_fabricator.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true Fabricator(:report) do - account - target_account { Fabricate(:account) } + account { Fabricate.build(:account) } + target_account { Fabricate.build(:account) } comment 'You nasty' action_taken_at nil end diff --git a/spec/fabricators/report_note_fabricator.rb b/spec/fabricators/report_note_fabricator.rb index f257fe2b7..080fad51a 100644 --- a/spec/fabricators/report_note_fabricator.rb +++ b/spec/fabricators/report_note_fabricator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Fabricator(:report_note) do - report - account { Fabricate(:account) } + report { Fabricate.build(:report) } + account { Fabricate.build(:account) } content 'Test Content' end diff --git a/spec/fabricators/scheduled_status_fabricator.rb b/spec/fabricators/scheduled_status_fabricator.rb index e517f258a..eed275ab9 100644 --- a/spec/fabricators/scheduled_status_fabricator.rb +++ b/spec/fabricators/scheduled_status_fabricator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true Fabricator(:scheduled_status) do - account + account { Fabricate.build(:account) } scheduled_at { 20.hours.from_now } end diff --git a/spec/fabricators/session_activation_fabricator.rb b/spec/fabricators/session_activation_fabricator.rb index b28d5e41d..4b5244cec 100644 --- a/spec/fabricators/session_activation_fabricator.rb +++ b/spec/fabricators/session_activation_fabricator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true Fabricator(:session_activation) do - user + user { Fabricate.build(:user) } session_id 'MyString' end diff --git a/spec/fabricators/status_fabricator.rb b/spec/fabricators/status_fabricator.rb index 17ac9ccd8..32a2cbf6a 100644 --- a/spec/fabricators/status_fabricator.rb +++ b/spec/fabricators/status_fabricator.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Fabricator(:status) do - account + account { Fabricate.build(:account) } text 'Lorem ipsum dolor sit amet' after_build do |status| diff --git a/spec/fabricators/status_pin_fabricator.rb b/spec/fabricators/status_pin_fabricator.rb index 9ad0ac9de..ceaaa34a7 100644 --- a/spec/fabricators/status_pin_fabricator.rb +++ b/spec/fabricators/status_pin_fabricator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true Fabricator(:status_pin) do - account - status { |attrs| Fabricate(:status, account: attrs[:account], visibility: :public) } + account { Fabricate.build(:account) } + status { |attrs| Fabricate.build(:status, account: attrs[:account], visibility: :public) } end diff --git a/spec/fabricators/tag_follow_fabricator.rb b/spec/fabricators/tag_follow_fabricator.rb index cbe5b0989..014435d60 100644 --- a/spec/fabricators/tag_follow_fabricator.rb +++ b/spec/fabricators/tag_follow_fabricator.rb @@ -2,5 +2,5 @@ Fabricator(:tag_follow) do tag - account + account { Fabricate.build(:account) } end