From 820b01726961f16ed9290cbd2c8ddd8009d11e8b Mon Sep 17 00:00:00 2001 From: James Smith Date: Tue, 26 Nov 2024 16:10:54 +0000 Subject: [PATCH] fix object POST in flag test --- spec/requests/reports_spec.rb | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/spec/requests/reports_spec.rb b/spec/requests/reports_spec.rb index ce636ba..345aeed 100644 --- a/spec/requests/reports_spec.rb +++ b/spec/requests/reports_spec.rb @@ -1,27 +1,23 @@ RSpec.describe "Reports" do let(:user) { create :user } - let(:report_body) { - <<-EOF - { - "@context":"https://www.w3.org/ns/activitystreams", - "id":"https://mastodon.me.uk/d977f377-214b-4efd-8a47-70a37fb7ea20", - "type":"Flag", - "actor":"https://mastodon.me.uk/actor", - "content":"Test, please ignore", - "object":[ - "https://example.com/models/abc123" - ] - } - EOF - } + let(:report_body) { { + "@context": "https://www.w3.org/ns/activitystreams", + "id": "https://mastodon.me.uk/d977f377-214b-4efd-8a47-70a37fb7ea20", + "type": "Flag", + "actor": "https://mastodon.me.uk/actor", + "content": "Test, please ignore", + "object": [ + "https://example.com/models/abc123" + ] + } } it "should accept Flag activities" do - post user.actor.inbox_url, params: report_body, headers: { content_type: "application/activity" } - expect(response.status).to be :created + post user.actor.inbox_url, params: report_body, as: :json + expect(response.status).to eq 201 end it "should call registered Report handler when a flag is received by Federails" do expect(Federails::Moderation::Report).to receive(:handle_flag).once.and_call_original - post user.actor.inbox_url, params: report_body, headers: { content_type: "application/activity" } + post user.actor.inbox_url, params: report_body, as: :json end end