2023-02-22 01:55:31 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-06-09 20:12:40 +02:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2024-01-22 12:58:54 +01:00
|
|
|
RSpec.describe 'API V1 Statuses Reblogged by Accounts' do
|
|
|
|
let(:user) { Fabricate(:user) }
|
|
|
|
let(:scopes) { 'read:accounts' }
|
|
|
|
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
|
|
|
|
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
|
2019-12-31 00:55:32 +01:00
|
|
|
let(:alice) { Fabricate(:account) }
|
|
|
|
let(:bob) { Fabricate(:account) }
|
2017-06-09 20:12:40 +02:00
|
|
|
|
|
|
|
context 'with an oauth token' do
|
2024-01-22 12:58:54 +01:00
|
|
|
subject do
|
|
|
|
get "/api/v1/statuses/#{status.id}/reblogged_by", headers: headers, params: { limit: 2 }
|
2017-06-09 20:12:40 +02:00
|
|
|
end
|
|
|
|
|
2024-01-22 12:58:54 +01:00
|
|
|
describe 'GET /api/v1/statuses/:status_id/reblogged_by' do
|
2017-06-09 20:12:40 +02:00
|
|
|
let(:status) { Fabricate(:status, account: user.account) }
|
|
|
|
|
|
|
|
before do
|
2019-12-31 00:55:32 +01:00
|
|
|
Fabricate(:status, account: alice, reblog_of_id: status.id)
|
|
|
|
Fabricate(:status, account: bob, reblog_of_id: status.id)
|
2017-06-09 20:12:40 +02:00
|
|
|
end
|
|
|
|
|
2023-10-13 14:42:09 +02:00
|
|
|
it 'returns accounts who reblogged the status', :aggregate_failures do
|
2024-01-22 12:58:54 +01:00
|
|
|
subject
|
|
|
|
|
|
|
|
expect(response)
|
|
|
|
.to have_http_status(200)
|
2024-07-12 10:30:52 +02:00
|
|
|
.and include_pagination_headers(
|
|
|
|
prev: api_v1_status_reblogged_by_index_url(limit: 2, since_id: bob.statuses.first.id),
|
|
|
|
next: api_v1_status_reblogged_by_index_url(limit: 2, max_id: alice.statuses.first.id)
|
|
|
|
)
|
2024-01-22 12:58:54 +01:00
|
|
|
|
|
|
|
expect(body_as_json.size)
|
|
|
|
.to eq(2)
|
|
|
|
expect(body_as_json)
|
|
|
|
.to contain_exactly(
|
|
|
|
include(id: alice.id.to_s),
|
|
|
|
include(id: bob.id.to_s)
|
|
|
|
)
|
2019-12-31 00:55:32 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not return blocked users' do
|
|
|
|
user.account.block!(bob)
|
2024-01-22 12:58:54 +01:00
|
|
|
|
|
|
|
subject
|
|
|
|
|
|
|
|
expect(body_as_json.size)
|
|
|
|
.to eq 1
|
|
|
|
expect(body_as_json.first[:id]).to eq(alice.id.to_s)
|
2019-12-31 00:55:32 +01:00
|
|
|
end
|
2017-06-09 20:12:40 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'without an oauth token' do
|
2024-01-22 12:58:54 +01:00
|
|
|
subject do
|
|
|
|
get "/api/v1/statuses/#{status.id}/reblogged_by", params: { limit: 2 }
|
2017-06-09 20:12:40 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'with a private status' do
|
|
|
|
let(:status) { Fabricate(:status, account: user.account, visibility: :private) }
|
|
|
|
|
|
|
|
describe 'GET #index' do
|
|
|
|
before do
|
|
|
|
Fabricate(:status, reblog_of_id: status.id)
|
|
|
|
end
|
|
|
|
|
2022-03-06 22:51:40 +01:00
|
|
|
it 'returns http unauthorized' do
|
2024-01-22 12:58:54 +01:00
|
|
|
subject
|
|
|
|
|
2018-04-21 21:35:07 +02:00
|
|
|
expect(response).to have_http_status(404)
|
2017-06-09 20:12:40 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with a public status' do
|
|
|
|
let(:status) { Fabricate(:status, account: user.account, visibility: :public) }
|
|
|
|
|
|
|
|
describe 'GET #index' do
|
|
|
|
before do
|
|
|
|
Fabricate(:status, reblog_of_id: status.id)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns http success' do
|
2024-01-22 12:58:54 +01:00
|
|
|
subject
|
|
|
|
|
2018-04-21 21:35:07 +02:00
|
|
|
expect(response).to have_http_status(200)
|
2017-06-09 20:12:40 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|