Rework FEP-7888 implementation (#36064)
This commit is contained in:
@@ -3,10 +3,10 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'ActivityPub Contexts' do
|
||||
let(:conversation) { Fabricate(:conversation) }
|
||||
let(:conversation) { Fabricate(:status).owned_conversation }
|
||||
|
||||
describe 'GET #show' do
|
||||
subject { get context_path(id: conversation.id), headers: nil }
|
||||
subject { get context_path(conversation), headers: nil }
|
||||
|
||||
let!(:status) { Fabricate(:status, conversation: conversation) }
|
||||
let!(:unrelated_status) { Fabricate(:status) }
|
||||
@@ -26,17 +26,39 @@ RSpec.describe 'ActivityPub Contexts' do
|
||||
|
||||
expect(response.parsed_body[:first][:items])
|
||||
.to be_an(Array)
|
||||
.and have_attributes(size: 1)
|
||||
.and have_attributes(size: 2)
|
||||
.and include(ActivityPub::TagManager.instance.uri_for(status))
|
||||
.and not_include(ActivityPub::TagManager.instance.uri_for(unrelated_status))
|
||||
end
|
||||
|
||||
context 'when the initial account is deleted' do
|
||||
before { conversation.parent_account.delete }
|
||||
|
||||
it 'returns http success and correct media type and correct items' do
|
||||
subject
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and have_cacheable_headers
|
||||
|
||||
expect(response.media_type)
|
||||
.to eq 'application/activity+json'
|
||||
|
||||
expect(response.parsed_body[:type])
|
||||
.to eq 'Collection'
|
||||
|
||||
expect(response.parsed_body[:first][:items])
|
||||
.to be_an(Array)
|
||||
.and have_attributes(size: 1)
|
||||
.and include(ActivityPub::TagManager.instance.uri_for(status))
|
||||
.and not_include(ActivityPub::TagManager.instance.uri_for(unrelated_status))
|
||||
end
|
||||
end
|
||||
|
||||
context 'with pagination' do
|
||||
context 'with few statuses' do
|
||||
before do
|
||||
3.times do
|
||||
Fabricate(:status, conversation: conversation)
|
||||
end
|
||||
Fabricate.times(3, :status, conversation: conversation)
|
||||
end
|
||||
|
||||
it 'does not include a next page link' do
|
||||
@@ -48,7 +70,7 @@ RSpec.describe 'ActivityPub Contexts' do
|
||||
|
||||
context 'with many statuses' do
|
||||
before do
|
||||
(ActivityPub::ContextsController::DESCENDANTS_LIMIT + 1).times do
|
||||
ActivityPub::ContextsController::DESCENDANTS_LIMIT.times do
|
||||
Fabricate(:status, conversation: conversation)
|
||||
end
|
||||
end
|
||||
@@ -63,13 +85,11 @@ RSpec.describe 'ActivityPub Contexts' do
|
||||
end
|
||||
|
||||
describe 'GET #items' do
|
||||
subject { get items_context_path(id: conversation.id, page: 0, min_id: nil), headers: nil }
|
||||
subject { get items_context_path(conversation, page: 0, min_id: nil), headers: nil }
|
||||
|
||||
context 'with few statuses' do
|
||||
before do
|
||||
3.times do
|
||||
Fabricate(:status, conversation: conversation)
|
||||
end
|
||||
Fabricate.times(2, :status, conversation: conversation)
|
||||
end
|
||||
|
||||
it 'returns http success and correct media type and correct items' do
|
||||
@@ -94,9 +114,8 @@ RSpec.describe 'ActivityPub Contexts' do
|
||||
|
||||
context 'with many statuses' do
|
||||
before do
|
||||
(ActivityPub::ContextsController::DESCENDANTS_LIMIT + 1).times do
|
||||
Fabricate(:status, conversation: conversation)
|
||||
end
|
||||
stub_const 'ActivityPub::ContextsController::DESCENDANTS_LIMIT', 2
|
||||
Fabricate.times(ActivityPub::ContextsController::DESCENDANTS_LIMIT, :status, conversation: conversation)
|
||||
end
|
||||
|
||||
it 'includes a next page link' do
|
||||
@@ -108,13 +127,12 @@ RSpec.describe 'ActivityPub Contexts' do
|
||||
|
||||
context 'with page requested' do
|
||||
before do
|
||||
(ActivityPub::ContextsController::DESCENDANTS_LIMIT + 1).times do |_i|
|
||||
Fabricate(:status, conversation: conversation)
|
||||
end
|
||||
stub_const 'ActivityPub::ContextsController::DESCENDANTS_LIMIT', 2
|
||||
Fabricate.times(ActivityPub::ContextsController::DESCENDANTS_LIMIT, :status, conversation: conversation)
|
||||
end
|
||||
|
||||
it 'returns the correct items' do
|
||||
get items_context_path(id: conversation.id, page: 0, min_id: nil), headers: nil
|
||||
get items_context_path(conversation, page: 0, min_id: nil), headers: nil
|
||||
next_page = response.parsed_body['first']['next']
|
||||
get next_page, headers: nil
|
||||
|
||||
|
||||
Reference in New Issue
Block a user