The code powering m.abunchtell.com https://m.abunchtell.com
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 

80 lignes
2.0 KiB

  1. require 'rails_helper'
  2. RSpec.describe ActivityPub::Activity::Follow do
  3. let(:sender) { Fabricate(:account) }
  4. let(:recipient) { Fabricate(:account) }
  5. let(:json) do
  6. {
  7. '@context': 'https://www.w3.org/ns/activitystreams',
  8. id: 'foo',
  9. type: 'Follow',
  10. actor: ActivityPub::TagManager.instance.uri_for(sender),
  11. object: ActivityPub::TagManager.instance.uri_for(recipient),
  12. }.with_indifferent_access
  13. end
  14. describe '#perform' do
  15. subject { described_class.new(json, sender) }
  16. context 'unlocked account' do
  17. before do
  18. subject.perform
  19. end
  20. it 'creates a follow from sender to recipient' do
  21. expect(sender.following?(recipient)).to be true
  22. end
  23. it 'does not create a follow request' do
  24. expect(sender.requested?(recipient)).to be false
  25. end
  26. end
  27. context 'silenced account following an unlocked account' do
  28. before do
  29. sender.touch(:silenced_at)
  30. subject.perform
  31. end
  32. it 'does not create a follow from sender to recipient' do
  33. expect(sender.following?(recipient)).to be false
  34. end
  35. it 'creates a follow request' do
  36. expect(sender.requested?(recipient)).to be true
  37. end
  38. end
  39. context 'unlocked account muting the sender' do
  40. before do
  41. recipient.mute!(sender)
  42. subject.perform
  43. end
  44. it 'creates a follow from sender to recipient' do
  45. expect(sender.following?(recipient)).to be true
  46. end
  47. it 'does not create a follow request' do
  48. expect(sender.requested?(recipient)).to be false
  49. end
  50. end
  51. context 'locked account' do
  52. before do
  53. recipient.update(locked: true)
  54. subject.perform
  55. end
  56. it 'does not create a follow from sender to recipient' do
  57. expect(sender.following?(recipient)).to be false
  58. end
  59. it 'creates a follow request' do
  60. expect(sender.requested?(recipient)).to be true
  61. end
  62. end
  63. end
  64. end