Add circle/mutuals test
This commit is contained in:
parent
4752c8f032
commit
af44c20d50
2 changed files with 36 additions and 0 deletions
|
@ -9,6 +9,8 @@ describe AccountInteractions do
|
|||
let(:target_account) { Fabricate(:account, username: 'target') }
|
||||
let(:target_account_id) { target_account.id }
|
||||
let(:target_account_ids) { [target_account_id] }
|
||||
let(:follower_account) { Fabricate(:account, username: 'follower') }
|
||||
let(:followee_account) { Fabricate(:account, username: 'followee') }
|
||||
|
||||
describe '.following_map' do
|
||||
subject { Account.following_map(target_account_ids, account_id) }
|
||||
|
@ -711,4 +713,20 @@ describe AccountInteractions do
|
|||
expect(account.lists_for_local_distribution.to_a).to contain_exactly(follower_list, self_list)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#mutuals' do
|
||||
subject { account.mutuals }
|
||||
|
||||
context 'when following target_account' do
|
||||
it 'mutual one' do
|
||||
account.follow!(target_account)
|
||||
target_account.follow!(account)
|
||||
follower_account.follow!(account)
|
||||
account.follow!(followee_account)
|
||||
|
||||
expect(subject.count).to eq 1
|
||||
expect(subject.first.id).to eq target_account.id
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -188,6 +188,24 @@ RSpec.describe PostStatusService, type: :service do
|
|||
expect(status.mentioned_accounts.first.id).to eq mutual_account.id
|
||||
end
|
||||
|
||||
it 'circle visibility' do
|
||||
account = Fabricate(:account)
|
||||
circle_account = Fabricate(:account)
|
||||
other_account = Fabricate(:account)
|
||||
circle = Fabricate(:circle, account: account)
|
||||
text = 'This is an English text.'
|
||||
|
||||
circle_account.follow!(account)
|
||||
other_account.follow!(account)
|
||||
circle.accounts << circle_account
|
||||
status = subject.call(account, text: text, visibility: 'circle', circle_id: circle.id)
|
||||
|
||||
expect(status.visibility).to eq 'limited'
|
||||
expect(status.limited_scope).to eq 'circle'
|
||||
expect(status.mentioned_accounts.count).to eq 1
|
||||
expect(status.mentioned_accounts.first.id).to eq circle_account.id
|
||||
end
|
||||
|
||||
it 'safeguards mentions' do
|
||||
account = Fabricate(:account)
|
||||
mentioned_account = Fabricate(:account, username: 'alice')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue