From da61842b60d80434f988daae9fd4f4cbb78cc456 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Sun, 9 Jun 2024 14:21:44 -0400 Subject: [PATCH] Use fabricator in account key specs --- spec/models/account_spec.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 225929ae39..549540e1cb 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -1015,21 +1015,22 @@ RSpec.describe Account do context 'when is local' do it 'generates keys' do - account = described_class.create!(domain: nil, username: Faker::Internet.user_name(separators: ['_'])) - expect(account.keypair).to be_private - expect(account.keypair).to be_public + account = Fabricate(:account, domain: nil) + expect(account.keypair) + .to be_private + .and be_public end end context 'when is remote' do it 'does not generate keys' do key = OpenSSL::PKey::RSA.new(1024).public_key - account = described_class.create!(domain: 'remote', uri: 'https://remote/actor', username: Faker::Internet.user_name(separators: ['_']), public_key: key.to_pem) + account = Fabricate(:account, domain: 'remote', uri: 'https://remote/actor', public_key: key.to_pem, private_key: nil) expect(account.keypair.params).to eq key.params end it 'normalizes domain' do - account = described_class.create!(domain: 'にゃん', uri: 'https://xn--r9j5b5b/actor', username: Faker::Internet.user_name(separators: ['_'])) + account = Fabricate(:account, domain: 'にゃん', uri: 'https://xn--r9j5b5b/actor') expect(account.domain).to eq 'xn--r9j5b5b' end end