mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-08 10:50:58 +00:00
Add coverage for Account.representative
from finder concern
This commit is contained in:
parent
5d9a9c76fb
commit
15df22eb2e
|
@ -3,6 +3,37 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe Account::FinderConcern do
|
RSpec.describe Account::FinderConcern do
|
||||||
|
describe '.representative' do
|
||||||
|
context 'with an instance actor using an invalid legacy username' do
|
||||||
|
let(:legacy_value) { 'legacy:value' }
|
||||||
|
|
||||||
|
before { Account.find(Account::INSTANCE_ACTOR_ID).update_attribute(:username, legacy_value) }
|
||||||
|
|
||||||
|
it 'updates the username to the new value' do
|
||||||
|
expect { Account.representative }
|
||||||
|
.to change { Account.find(Account::INSTANCE_ACTOR_ID).username }.from(legacy_value).to('mastodon.internal')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'without an instance actor' do
|
||||||
|
before { Account.find(Account::INSTANCE_ACTOR_ID).destroy! }
|
||||||
|
|
||||||
|
it 'creates an instance actor' do
|
||||||
|
expect { Account.representative }
|
||||||
|
.to change(Account.where(id: Account::INSTANCE_ACTOR_ID), :count).from(0).to(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with a correctly loaded instance actor' do
|
||||||
|
let(:instance_actor) { Account.find(Account::INSTANCE_ACTOR_ID) }
|
||||||
|
|
||||||
|
it 'returns the instance actor record' do
|
||||||
|
expect(Account.representative)
|
||||||
|
.to eq(instance_actor)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'local finders' do
|
describe 'local finders' do
|
||||||
let!(:account) { Fabricate(:account, username: 'Alice') }
|
let!(:account) { Fabricate(:account, username: 'Alice') }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user