familiar_followers_presenter_spec.rb 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe FamiliarFollowersPresenter do
  4. describe '#accounts' do
  5. let(:account) { Fabricate(:account) }
  6. let(:familiar_follower) { Fabricate(:account) }
  7. let(:requested_accounts) { Fabricate.times(2, :account) }
  8. subject { described_class.new(requested_accounts, account.id) }
  9. before do
  10. familiar_follower.follow!(requested_accounts.first)
  11. account.follow!(familiar_follower)
  12. end
  13. it 'returns a result for each requested account' do
  14. expect(subject.accounts.map(&:id)).to eq requested_accounts.map(&:id)
  15. end
  16. it 'returns followers you follow' do
  17. result = subject.accounts.first
  18. expect(result).to_not be_nil
  19. expect(result.id).to eq requested_accounts.first.id
  20. expect(result.accounts).to match_array([familiar_follower])
  21. end
  22. context 'when requested account hides followers' do
  23. before do
  24. requested_accounts.first.update(hide_collections: true)
  25. end
  26. it 'does not return followers you follow' do
  27. result = subject.accounts.first
  28. expect(result).to_not be_nil
  29. expect(result.id).to eq requested_accounts.first.id
  30. expect(result.accounts).to be_empty
  31. end
  32. end
  33. context 'when familiar follower hides follows' do
  34. before do
  35. familiar_follower.update(hide_collections: true)
  36. end
  37. it 'does not return followers you follow' do
  38. result = subject.accounts.first
  39. expect(result).to_not be_nil
  40. expect(result.id).to eq requested_accounts.first.id
  41. expect(result.accounts).to be_empty
  42. end
  43. end
  44. end
  45. end