list_account_spec.rb 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe ListAccount do
  4. describe 'Callbacks to set follows' do
  5. context 'when list owner follows account' do
  6. let!(:follow) { Fabricate :follow }
  7. let(:list) { Fabricate :list, account: follow.account }
  8. it 'finds and sets the follow with the list account' do
  9. list_account = Fabricate :list_account, list: list, account: follow.target_account
  10. expect(list_account)
  11. .to have_attributes(
  12. follow: eq(follow),
  13. follow_request: be_nil
  14. )
  15. end
  16. end
  17. context 'when list owner has a follow request for account' do
  18. let!(:follow_request) { Fabricate :follow_request }
  19. let(:list) { Fabricate :list, account: follow_request.account }
  20. it 'finds and sets the follow request with the list account' do
  21. list_account = Fabricate :list_account, list: list, account: follow_request.target_account
  22. expect(list_account)
  23. .to have_attributes(
  24. follow: be_nil,
  25. follow_request: eq(follow_request)
  26. )
  27. end
  28. end
  29. context 'when list owner is the account' do
  30. it 'does not set follow or follow request' do
  31. list_account = Fabricate :list_account
  32. expect(list_account)
  33. .to have_attributes(
  34. follow: be_nil,
  35. follow_request: be_nil
  36. )
  37. end
  38. end
  39. end
  40. end