Skip to content

Commit

Permalink
Add circle/mutuals test
Browse files Browse the repository at this point in the history
  • Loading branch information
kmycode committed Sep 11, 2023
1 parent 4752c8f commit af44c20
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
18 changes: 18 additions & 0 deletions spec/models/concerns/account_interactions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
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) }
Expand Down Expand Up @@ -711,4 +713,20 @@
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
18 changes: 18 additions & 0 deletions spec/services/post_status_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,24 @@
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')
Expand Down

0 comments on commit af44c20

Please sign in to comment.