1
0

account_fabricator.rb 814 B

123456789101112131415161718
  1. # frozen_string_literal: true
  2. keypair = OpenSSL::PKey::RSA.new(2048)
  3. public_key = keypair.public_key.to_pem
  4. private_key = keypair.to_pem
  5. Fabricator(:account) do
  6. transient :suspended, :silenced
  7. username { sequence(:username) { |i| "#{Faker::Internet.user_name(separators: %w(_))}#{i}" } }
  8. last_webfingered_at { Time.now.utc }
  9. public_key { public_key }
  10. private_key { private_key }
  11. suspended_at { |attrs| attrs[:suspended] ? Time.now.utc : nil }
  12. silenced_at { |attrs| attrs[:silenced] ? Time.now.utc : nil }
  13. user { |attrs| attrs[:domain].nil? ? Fabricate.build(:user, account: nil) : nil }
  14. uri { |attrs| attrs[:domain].nil? ? '' : "https://#{attrs[:domain]}/users/#{attrs[:username]}" }
  15. discoverable true
  16. end