From 67403e7b01f22c3089c7062f9f4e8e861357c377 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Wed, 23 Oct 2024 02:41:07 -0400 Subject: [PATCH] Add coverage for ActivityPub likes/shares endpoints (#32305) --- spec/requests/activitypub/likes_spec.rb | 25 ++++++++++++++++++++++++ spec/requests/activitypub/shares_spec.rb | 25 ++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 spec/requests/activitypub/likes_spec.rb create mode 100644 spec/requests/activitypub/shares_spec.rb diff --git a/spec/requests/activitypub/likes_spec.rb b/spec/requests/activitypub/likes_spec.rb new file mode 100644 index 0000000000..d780ad5168 --- /dev/null +++ b/spec/requests/activitypub/likes_spec.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe 'ActivityPub Likes' do + let(:account) { Fabricate(:account) } + let(:status) { Fabricate :status, account: account } + + before { Fabricate :favourite, status: status } + + describe 'GET /accounts/:account_username/statuses/:status_id/likes' do + it 'returns http success and activity json types and correct items count' do + get account_status_likes_path(account, status) + + expect(response) + .to have_http_status(200) + expect(response.media_type) + .to eq 'application/activity+json' + + expect(response.parsed_body) + .to include(type: 'Collection') + .and include(totalItems: 1) + end + end +end diff --git a/spec/requests/activitypub/shares_spec.rb b/spec/requests/activitypub/shares_spec.rb new file mode 100644 index 0000000000..956bc7d201 --- /dev/null +++ b/spec/requests/activitypub/shares_spec.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe 'ActivityPub Shares' do + let(:account) { Fabricate(:account) } + let(:status) { Fabricate :status, account: account } + + before { Fabricate :status, reblog: status } + + describe 'GET /accounts/:account_username/statuses/:status_id/shares' do + it 'returns http success and activity json types and correct items count' do + get account_status_shares_path(account, status) + + expect(response) + .to have_http_status(200) + expect(response.media_type) + .to eq 'application/activity+json' + + expect(response.parsed_body) + .to include(type: 'Collection') + .and include(totalItems: 1) + end + end +end