logo

mastofe

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

flag_spec.rb (997B)


  1. require 'rails_helper'
  2. RSpec.describe ActivityPub::Activity::Flag do
  3. let(:sender) { Fabricate(:account, domain: 'example.com') }
  4. let(:flagged) { Fabricate(:account) }
  5. let(:status) { Fabricate(:status, account: flagged, uri: 'foobar') }
  6. let(:json) do
  7. {
  8. '@context': 'https://www.w3.org/ns/activitystreams',
  9. id: nil,
  10. type: 'Flag',
  11. content: 'Boo!!',
  12. actor: ActivityPub::TagManager.instance.uri_for(sender),
  13. object: [
  14. ActivityPub::TagManager.instance.uri_for(flagged),
  15. ActivityPub::TagManager.instance.uri_for(status),
  16. ],
  17. }.with_indifferent_access
  18. end
  19. describe '#perform' do
  20. subject { described_class.new(json, sender) }
  21. before do
  22. subject.perform
  23. end
  24. it 'creates a report' do
  25. report = Report.find_by(account: sender, target_account: flagged)
  26. expect(report).to_not be_nil
  27. expect(report.comment).to eq 'Boo!!'
  28. expect(report.status_ids).to eq [status.id]
  29. end
  30. end
  31. end