logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

undo_spec.rb (2980B)


  1. require 'rails_helper'
  2. RSpec.describe ActivityPub::Activity::Undo do
  3. let(:sender) { Fabricate(:account, domain: 'example.com') }
  4. let(:json) do
  5. {
  6. '@context': 'https://www.w3.org/ns/activitystreams',
  7. id: 'foo',
  8. type: 'Undo',
  9. actor: ActivityPub::TagManager.instance.uri_for(sender),
  10. object: object_json,
  11. }.with_indifferent_access
  12. end
  13. subject { described_class.new(json, sender) }
  14. describe '#perform' do
  15. context 'with Announce' do
  16. let(:status) { Fabricate(:status) }
  17. let(:object_json) do
  18. {
  19. id: 'bar',
  20. type: 'Announce',
  21. actor: ActivityPub::TagManager.instance.uri_for(sender),
  22. object: ActivityPub::TagManager.instance.uri_for(status),
  23. atomUri: 'barbar',
  24. }
  25. end
  26. context do
  27. before do
  28. Fabricate(:status, reblog: status, account: sender, uri: 'bar')
  29. end
  30. it 'deletes the reblog' do
  31. subject.perform
  32. expect(sender.reblogged?(status)).to be false
  33. end
  34. end
  35. context 'with atomUri' do
  36. before do
  37. Fabricate(:status, reblog: status, account: sender, uri: 'barbar')
  38. end
  39. it 'deletes the reblog by atomUri' do
  40. subject.perform
  41. expect(sender.reblogged?(status)).to be false
  42. end
  43. end
  44. end
  45. context 'with Block' do
  46. let(:recipient) { Fabricate(:account) }
  47. let(:object_json) do
  48. {
  49. id: 'bar',
  50. type: 'Block',
  51. actor: ActivityPub::TagManager.instance.uri_for(sender),
  52. object: ActivityPub::TagManager.instance.uri_for(recipient),
  53. }
  54. end
  55. before do
  56. sender.block!(recipient)
  57. end
  58. it 'deletes block from sender to recipient' do
  59. subject.perform
  60. expect(sender.blocking?(recipient)).to be false
  61. end
  62. end
  63. context 'with Follow' do
  64. let(:recipient) { Fabricate(:account) }
  65. let(:object_json) do
  66. {
  67. id: 'bar',
  68. type: 'Follow',
  69. actor: ActivityPub::TagManager.instance.uri_for(sender),
  70. object: ActivityPub::TagManager.instance.uri_for(recipient),
  71. }
  72. end
  73. before do
  74. sender.follow!(recipient)
  75. end
  76. it 'deletes follow from sender to recipient' do
  77. subject.perform
  78. expect(sender.following?(recipient)).to be false
  79. end
  80. end
  81. context 'with Like' do
  82. let(:status) { Fabricate(:status) }
  83. let(:object_json) do
  84. {
  85. id: 'bar',
  86. type: 'Like',
  87. actor: ActivityPub::TagManager.instance.uri_for(sender),
  88. object: ActivityPub::TagManager.instance.uri_for(status),
  89. }
  90. end
  91. before do
  92. Fabricate(:favourite, account: sender, status: status)
  93. end
  94. it 'deletes favourite from sender to status' do
  95. subject.perform
  96. expect(sender.favourited?(status)).to be false
  97. end
  98. end
  99. end
  100. end