mirror of
https://github.com/lunaisnotaboy/mastodon.git
synced 2024-11-09 16:35:48 +00:00
e38fc319dc
* Change account and user fabricators to simplify and improve tests - `Fabricate(:account)` implicitly fabricates an associated `user` if no `domain` attribute is given (an account with `domain: nil` is considered a local account, but no user record was created), unless `user: nil` is passed - `Fabricate(:account, user: Fabricate(:user))` should still be possible but is discouraged. * Fix and refactor tests - avoid passing unneeded attributes to `Fabricate(:user)` or `Fabricate(:account)` - avoid embedding `Fabricate(:user)` into a `Fabricate(:account)` or the other way around - prefer `Fabricate(:user, account_attributes: …)` to `Fabricate(:user, account: Fabricate(:account, …)` - also, some tests were using remote accounts with local user records, which is not representative of production code.
15 lines
641 B
Ruby
15 lines
641 B
Ruby
keypair = OpenSSL::PKey::RSA.new(2048)
|
|
public_key = keypair.public_key.to_pem
|
|
private_key = keypair.to_pem
|
|
|
|
Fabricator(:account) do
|
|
transient :suspended, :silenced
|
|
username { sequence(:username) { |i| "#{Faker::Internet.user_name(separators: %w(_))}#{i}" } }
|
|
last_webfingered_at { Time.now.utc }
|
|
public_key { public_key }
|
|
private_key { private_key }
|
|
suspended_at { |attrs| attrs[:suspended] ? Time.now.utc : nil }
|
|
silenced_at { |attrs| attrs[:silenced] ? Time.now.utc : nil }
|
|
user { |attrs| attrs[:domain].nil? ? Fabricate.build(:user, account: nil) : nil }
|
|
end
|