Change `ids` param to `id` in `/api/v1/statuses` and `/api/v1/accounts` for consistency (#30465)

This commit is contained in:
Claire 2024-05-29 11:19:17 +02:00 committed by GitHub
parent 5d7d23999c
commit 36fe8f8566
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 8 additions and 8 deletions

View File

@ -106,11 +106,11 @@ class Api::V1::AccountsController < Api::BaseController
end end
def account_ids def account_ids
Array(accounts_params[:ids]).uniq.map(&:to_i) Array(accounts_params[:id]).uniq.map(&:to_i)
end end
def accounts_params def accounts_params
params.permit(ids: []) params.permit(id: [])
end end
def account_params def account_params

View File

@ -141,11 +141,11 @@ class Api::V1::StatusesController < Api::BaseController
end end
def status_ids def status_ids
Array(statuses_params[:ids]).uniq.map(&:to_i) Array(statuses_params[:id]).uniq.map(&:to_i)
end end
def statuses_params def statuses_params
params.permit(ids: []) params.permit(id: [])
end end
def status_params def status_params

View File

@ -8,13 +8,13 @@ describe '/api/v1/accounts' do
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) } let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } } let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
describe 'GET /api/v1/accounts?ids[]=:id' do describe 'GET /api/v1/accounts?id[]=:id' do
let(:account) { Fabricate(:account) } let(:account) { Fabricate(:account) }
let(:other_account) { Fabricate(:account) } let(:other_account) { Fabricate(:account) }
let(:scopes) { 'read:accounts' } let(:scopes) { 'read:accounts' }
it 'returns expected response' do it 'returns expected response' do
get '/api/v1/accounts', headers: headers, params: { ids: [account.id, other_account.id, 123_123] } get '/api/v1/accounts', headers: headers, params: { id: [account.id, other_account.id, 123_123] }
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to contain_exactly( expect(body_as_json).to contain_exactly(

View File

@ -9,13 +9,13 @@ describe '/api/v1/statuses' do
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, application: client_app, scopes: scopes) } let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, application: client_app, scopes: scopes) }
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } } let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
describe 'GET /api/v1/statuses?ids[]=:id' do describe 'GET /api/v1/statuses?id[]=:id' do
let(:status) { Fabricate(:status) } let(:status) { Fabricate(:status) }
let(:other_status) { Fabricate(:status) } let(:other_status) { Fabricate(:status) }
let(:scopes) { 'read:statuses' } let(:scopes) { 'read:statuses' }
it 'returns expected response' do it 'returns expected response' do
get '/api/v1/statuses', headers: headers, params: { ids: [status.id, other_status.id, 123_123] } get '/api/v1/statuses', headers: headers, params: { id: [status.id, other_status.id, 123_123] }
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to contain_exactly( expect(body_as_json).to contain_exactly(