1
0

familiar_followers_presenter_spec.rb 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe FamiliarFollowersPresenter do
  4. describe '#accounts' do
  5. subject { described_class.new(requested_accounts, account.id) }
  6. let(:account) { Fabricate(:account) }
  7. let(:familiar_follower) { Fabricate(:account) }
  8. let(:requested_accounts) { Fabricate.times(2, :account) }
  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)
  19. .to be_present
  20. .and have_attributes(
  21. id: requested_accounts.first.id,
  22. accounts: contain_exactly(familiar_follower)
  23. )
  24. end
  25. context 'when requested account hides followers' do
  26. before do
  27. requested_accounts.first.update(hide_collections: true)
  28. end
  29. it 'does not return followers you follow' do
  30. result = subject.accounts.first
  31. expect(result)
  32. .to be_present
  33. .and have_attributes(
  34. id: requested_accounts.first.id,
  35. accounts: be_empty
  36. )
  37. end
  38. end
  39. context 'when familiar follower hides follows' do
  40. before do
  41. familiar_follower.update(hide_collections: true)
  42. end
  43. it 'does not return followers you follow' do
  44. result = subject.accounts.first
  45. expect(result)
  46. .to be_present
  47. .and have_attributes(
  48. id: requested_accounts.first.id,
  49. accounts: be_empty
  50. )
  51. end
  52. end
  53. end
  54. end