Revert to not indexing by id

This commit is contained in:
Claire 2024-04-24 15:07:20 +02:00
parent 69253d65c8
commit 6b20cfdab4
4 changed files with 8 additions and 8 deletions

View file

@ -22,7 +22,7 @@ class Api::V1::AccountsController < Api::BaseController
override_rate_limit_headers :follow, family: :follows
def index
render json: @accounts.map { |account| ActiveModelSerializers::SerializableResource.new(account, serializer: REST::AccountSerializer, scope: current_user, scope_name: :current_user).as_json }.index_by { |account| account[:id] }
render json: @accounts, each_serializer: REST::AccountSerializer
end
def show

View file

@ -27,7 +27,7 @@ class Api::V1::StatusesController < Api::BaseController
def index
@statuses = cache_collection(@statuses, Status)
render json: @statuses.map { |status| ActiveModelSerializers::SerializableResource.new(status, serializer: REST::StatusSerializer, scope: current_user, scope_name: :current_user).as_json }.index_by { |status| status[:id] }
render json: @statuses, each_serializer: REST::StatusSerializer
end
def show

View file

@ -17,9 +17,9 @@ describe '/api/v1/accounts' do
get '/api/v1/accounts', headers: headers, params: { ids: [account.id, other_account.id, 123_123] }
expect(response).to have_http_status(200)
expect(body_as_json.with_indifferent_access).to include(
account.id.to_s.to_s => include(id: account.id.to_s),
other_account.id.to_s => include(id: other_account.id.to_s)
expect(body_as_json).to contain_exactly(
hash_including(id: account.id.to_s),
hash_including(id: other_account.id.to_s)
)
end
end

View file

@ -18,9 +18,9 @@ describe '/api/v1/statuses' do
get '/api/v1/statuses', headers: headers, params: { ids: [status.id, other_status.id, 123_123] }
expect(response).to have_http_status(200)
expect(body_as_json.with_indifferent_access).to include(
status.id.to_s => include(id: status.id.to_s),
other_status.id.to_s => include(id: other_status.id.to_s)
expect(body_as_json).to contain_exactly(
hash_including(id: status.id.to_s),
hash_including(id: other_status.id.to_s)
)
end
end