The code powering m.abunchtell.com https://m.abunchtell.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

86 lines
2.1 KiB

  1. require 'rails_helper'
  2. RSpec.describe ActivityPub::Activity::Block 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: 'Block',
  10. actor: ActivityPub::TagManager.instance.uri_for(sender),
  11. object: ActivityPub::TagManager.instance.uri_for(recipient),
  12. }.with_indifferent_access
  13. end
  14. context 'when the recipient does not follow the sender' do
  15. describe '#perform' do
  16. subject { described_class.new(json, sender) }
  17. before do
  18. subject.perform
  19. end
  20. it 'creates a block from sender to recipient' do
  21. expect(sender.blocking?(recipient)).to be true
  22. end
  23. end
  24. end
  25. context 'when the recipient follows the sender' do
  26. before do
  27. recipient.follow!(sender)
  28. end
  29. describe '#perform' do
  30. subject { described_class.new(json, sender) }
  31. before do
  32. subject.perform
  33. end
  34. it 'creates a block from sender to recipient' do
  35. expect(sender.blocking?(recipient)).to be true
  36. end
  37. it 'ensures recipient is not following sender' do
  38. expect(recipient.following?(sender)).to be false
  39. end
  40. end
  41. end
  42. context 'when a matching undo has been received first' do
  43. let(:undo_json) do
  44. {
  45. '@context': 'https://www.w3.org/ns/activitystreams',
  46. id: 'bar',
  47. type: 'Undo',
  48. actor: ActivityPub::TagManager.instance.uri_for(sender),
  49. object: json,
  50. }.with_indifferent_access
  51. end
  52. before do
  53. recipient.follow!(sender)
  54. ActivityPub::Activity::Undo.new(undo_json, sender).perform
  55. end
  56. describe '#perform' do
  57. subject { described_class.new(json, sender) }
  58. before do
  59. subject.perform
  60. end
  61. it 'does not create a block from sender to recipient' do
  62. expect(sender.blocking?(recipient)).to be false
  63. end
  64. it 'ensures recipient is not following sender' do
  65. expect(recipient.following?(sender)).to be false
  66. end
  67. end
  68. end
  69. end