2
0

Add quote_approval_policy parameter when posting and editing statuses (#35699)

This commit is contained in:
Claire
2025-08-06 16:23:12 +02:00
committed by GitHub
parent 6e48322055
commit 9ec99ffef1
5 changed files with 70 additions and 2 deletions

View File

@@ -158,6 +158,31 @@ RSpec.describe '/api/v1/statuses' do
end
end
context 'with a quote policy', feature: :outgoing_quotes do
let(:quoted_status) { Fabricate(:status, account: user.account) }
let(:params) do
{
status: 'Hello world, this is a self-quote',
quote_approval_policy: 'followers',
}
end
it 'returns post with appropriate quote policy, as well as rate limit headers', :aggregate_failures do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body[:quote_approval]).to include({
automatic: ['followers'],
manual: [],
current_user: 'automatic',
})
expect(response.headers['X-RateLimit-Limit']).to eq RateLimiter::FAMILIES[:statuses][:limit].to_s
expect(response.headers['X-RateLimit-Remaining']).to eq (RateLimiter::FAMILIES[:statuses][:limit] - 1).to_s
end
end
context 'with a self-quote post', feature: :outgoing_quotes do
let(:quoted_status) { Fabricate(:status, account: user.account) }
let(:params) do
@@ -307,9 +332,10 @@ RSpec.describe '/api/v1/statuses' do
describe 'PUT /api/v1/statuses/:id' do
subject do
put "/api/v1/statuses/#{status.id}", headers: headers, params: { status: 'I am updated' }
put "/api/v1/statuses/#{status.id}", headers: headers, params: params
end
let(:params) { { status: 'I am updated' } }
let(:scopes) { 'write:statuses' }
let(:status) { Fabricate(:status, account: user.account) }
@@ -323,6 +349,19 @@ RSpec.describe '/api/v1/statuses' do
.to start_with('application/json')
expect(status.reload.text).to eq 'I am updated'
end
context 'when updating only the quote policy' do
let(:params) { { status: status.text, quote_approval_policy: 'public' } }
it 'updates the status', :aggregate_failures, feature: :outgoing_quotes do
expect { subject }
.to change { status.reload.quote_approval_policy }.to(Status::QUOTE_APPROVAL_POLICY_FLAGS[:public] << 16)
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
end
end
end
end