mirror of
https://github.com/lunaisnotaboy/mastodon.git
synced 2024-11-22 14:53:15 +00:00
edf09ec747
* Add `/api/v1/accounts/familiar_followers` to REST API * Change hide network preference to be stored consistently for local and remote accounts * Add dummy classes to migration * Apply suggestions from code review Co-authored-by: Claire <claire.github-309c@sitedethib.com> Co-authored-by: Claire <claire.github-309c@sitedethib.com>
59 lines
1.6 KiB
Ruby
59 lines
1.6 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
RSpec.describe FamiliarFollowersPresenter do
|
|
describe '#accounts' do
|
|
let(:account) { Fabricate(:account) }
|
|
let(:familiar_follower) { Fabricate(:account) }
|
|
let(:requested_accounts) { Fabricate.times(2, :account) }
|
|
|
|
subject { described_class.new(requested_accounts, account.id) }
|
|
|
|
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
|
|
|
|
expect(result).to_not be_nil
|
|
expect(result.id).to eq requested_accounts.first.id
|
|
expect(result.accounts).to match_array([familiar_follower])
|
|
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
|
|
|
|
expect(result).to_not be_nil
|
|
expect(result.id).to eq requested_accounts.first.id
|
|
expect(result.accounts).to be_empty
|
|
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
|
|
|
|
expect(result).to_not be_nil
|
|
expect(result.id).to eq requested_accounts.first.id
|
|
expect(result.accounts).to be_empty
|
|
end
|
|
end
|
|
end
|
|
end
|