Use `build` where possible in fabricators (#25360)
This commit is contained in:
parent
c94bb9ba9a
commit
3a2a15c6ea
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Fabricator(:account_domain_block) do
|
||||
account
|
||||
account { Fabricate.build(:account) }
|
||||
domain 'example.com'
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Fabricator(:account_statuses_cleanup_policy) do
|
||||
account
|
||||
account { Fabricate.build(:account) }
|
||||
end
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Fabricator('Admin::ActionLog') do
|
||||
account
|
||||
account { Fabricate.build(:account) }
|
||||
action 'MyString'
|
||||
target nil
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Fabricator(:backup) do
|
||||
user
|
||||
user { Fabricate.build(:user) }
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Fabricator(:bookmark) do
|
||||
account
|
||||
status
|
||||
account { Fabricate.build(:account) }
|
||||
status { Fabricate.build(:status) }
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Fabricator(:bulk_import_row) do
|
||||
bulk_import
|
||||
bulk_import { Fabricate.build(:bulk_import) }
|
||||
data ''
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Fabricator(:custom_filter_keyword) do
|
||||
custom_filter
|
||||
custom_filter { Fabricate.build(:custom_filter) }
|
||||
keyword 'discourse'
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) }
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Fabricator(:favourite) do
|
||||
account
|
||||
status
|
||||
account { Fabricate.build(:account) }
|
||||
status { Fabricate.build(:status) }
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Fabricator(:identity) do
|
||||
user
|
||||
user { Fabricate.build(:user) }
|
||||
provider 'MyString'
|
||||
uid 'MyString'
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Fabricator(:invite) do
|
||||
user
|
||||
user { Fabricate.build(:user) }
|
||||
expires_at nil
|
||||
max_uses nil
|
||||
uses 0
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Fabricator(:list) do
|
||||
account
|
||||
account { Fabricate.build(:account) }
|
||||
title 'MyString'
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Fabricator(:media_attachment) do
|
||||
account
|
||||
account { Fabricate.build(:account) }
|
||||
|
||||
file do |attrs|
|
||||
case attrs[:type]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Fabricator(:mention) do
|
||||
account
|
||||
status
|
||||
account { Fabricate.build(:account) }
|
||||
status { Fabricate.build(:status) }
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
|
||||
Fabricator(:notification) do
|
||||
activity fabricator: :status
|
||||
account
|
||||
account { Fabricate.build(:account) }
|
||||
end
|
||||
|
|
|
@ -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) }
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Fabricator(:poll_vote) do
|
||||
account
|
||||
account { Fabricate.build(:account) }
|
||||
poll
|
||||
choice 0
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Fabricator(:scheduled_status) do
|
||||
account
|
||||
account { Fabricate.build(:account) }
|
||||
scheduled_at { 20.hours.from_now }
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Fabricator(:session_activation) do
|
||||
user
|
||||
user { Fabricate.build(:user) }
|
||||
session_id 'MyString'
|
||||
end
|
||||
|
|
|
@ -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|
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
|
||||
Fabricator(:tag_follow) do
|
||||
tag
|
||||
account
|
||||
account { Fabricate.build(:account) }
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue