2022-03-07 03:36:47 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe FamiliarFollowersPresenter do
|
|
|
|
describe '#accounts' do
|
2023-02-19 23:24:14 -05:00
|
|
|
subject { described_class.new(requested_accounts, account.id) }
|
|
|
|
|
2022-03-07 03:36:47 -05:00
|
|
|
let(:account) { Fabricate(:account) }
|
|
|
|
let(:familiar_follower) { Fabricate(:account) }
|
|
|
|
let(:requested_accounts) { Fabricate.times(2, :account) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
familiar_follower.follow!(requested_accounts.first)
|
|
|
|
account.follow!(familiar_follower)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns a result for each requested account' do
|
|
|
|
expect(subject.accounts.map(&:id)).to eq requested_accounts.map(&:id)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns followers you follow' do
|
|
|
|
result = subject.accounts.first
|
|
|
|
|
2023-11-16 09:37:52 -05:00
|
|
|
expect(result)
|
|
|
|
.to be_present
|
|
|
|
.and have_attributes(
|
|
|
|
id: requested_accounts.first.id,
|
|
|
|
accounts: contain_exactly(familiar_follower)
|
|
|
|
)
|
2022-03-07 03:36:47 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when requested account hides followers' do
|
|
|
|
before do
|
|
|
|
requested_accounts.first.update(hide_collections: true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not return followers you follow' do
|
|
|
|
result = subject.accounts.first
|
|
|
|
|
2023-11-16 09:37:52 -05:00
|
|
|
expect(result)
|
|
|
|
.to be_present
|
|
|
|
.and have_attributes(
|
|
|
|
id: requested_accounts.first.id,
|
|
|
|
accounts: be_empty
|
|
|
|
)
|
2022-03-07 03:36:47 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when familiar follower hides follows' do
|
|
|
|
before do
|
|
|
|
familiar_follower.update(hide_collections: true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not return followers you follow' do
|
|
|
|
result = subject.accounts.first
|
|
|
|
|
2023-11-16 09:37:52 -05:00
|
|
|
expect(result)
|
|
|
|
.to be_present
|
|
|
|
.and have_attributes(
|
|
|
|
id: requested_accounts.first.id,
|
|
|
|
accounts: be_empty
|
|
|
|
)
|
2022-03-07 03:36:47 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|