1
0

relationship_severance_event_spec.rb 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe RelationshipSeveranceEvent 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 '#import_from_active_follows!' do
  8. before do
  9. local_account.follow!(remote_account)
  10. end
  11. it 'imports the follow relationships with the expected direction' do
  12. event.import_from_active_follows!(local_account.active_relationships)
  13. relationships = event.severed_relationships.to_a
  14. expect(relationships.size).to eq 1
  15. expect(relationships[0].account).to eq local_account
  16. expect(relationships[0].target_account).to eq remote_account
  17. end
  18. end
  19. describe '#import_from_passive_follows!' do
  20. before do
  21. remote_account.follow!(local_account)
  22. end
  23. it 'imports the follow relationships with the expected direction' do
  24. event.import_from_passive_follows!(local_account.passive_relationships)
  25. relationships = event.severed_relationships.to_a
  26. expect(relationships.size).to eq 1
  27. expect(relationships[0].account).to eq remote_account
  28. expect(relationships[0].target_account).to eq local_account
  29. end
  30. end
  31. describe '#affected_local_accounts' do
  32. before do
  33. event.severed_relationships.create!(local_account: local_account, remote_account: remote_account, direction: :active)
  34. end
  35. it 'correctly lists local accounts' do
  36. expect(event.affected_local_accounts.to_a).to contain_exactly(local_account)
  37. end
  38. end
  39. end