severed_relationship_spec.rb 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe SeveredRelationship do
  4. let(:local_account) { Fabricate(:account) }
  5. let(:remote_account) { Fabricate(:account, domain: 'example.com') }
  6. let(:event) { Fabricate(:relationship_severance_event) }
  7. describe '#account' do
  8. context 'when the local account is the follower' do
  9. let(:severed_relationship) { Fabricate(:severed_relationship, relationship_severance_event: event, local_account: local_account, remote_account: remote_account, direction: :active) }
  10. it 'returns the local account' do
  11. expect(severed_relationship.account).to eq local_account
  12. end
  13. end
  14. context 'when the local account is being followed' do
  15. let(:severed_relationship) { Fabricate(:severed_relationship, relationship_severance_event: event, local_account: local_account, remote_account: remote_account, direction: :passive) }
  16. it 'returns the remote account' do
  17. expect(severed_relationship.account).to eq remote_account
  18. end
  19. end
  20. end
  21. describe '#target_account' do
  22. context 'when the local account is the follower' do
  23. let(:severed_relationship) { Fabricate(:severed_relationship, relationship_severance_event: event, local_account: local_account, remote_account: remote_account, direction: :active) }
  24. it 'returns the remote account' do
  25. expect(severed_relationship.target_account).to eq remote_account
  26. end
  27. end
  28. context 'when the local account is being followed' do
  29. let(:severed_relationship) { Fabricate(:severed_relationship, relationship_severance_event: event, local_account: local_account, remote_account: remote_account, direction: :passive) }
  30. it 'returns the local account' do
  31. expect(severed_relationship.target_account).to eq local_account
  32. end
  33. end
  34. end
  35. end