diff --git a/app/controllers/api/v1/accounts_controller.rb b/app/controllers/api/v1/accounts_controller.rb index 95540199fc..be7b302d3b 100644 --- a/app/controllers/api/v1/accounts_controller.rb +++ b/app/controllers/api/v1/accounts_controller.rb @@ -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 diff --git a/app/controllers/api/v1/statuses_controller.rb b/app/controllers/api/v1/statuses_controller.rb index fb99d3de7f..36a9ec6325 100644 --- a/app/controllers/api/v1/statuses_controller.rb +++ b/app/controllers/api/v1/statuses_controller.rb @@ -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 diff --git a/spec/requests/api/v1/accounts_spec.rb b/spec/requests/api/v1/accounts_spec.rb index f11df1335b..55f8e1c6fa 100644 --- a/spec/requests/api/v1/accounts_spec.rb +++ b/spec/requests/api/v1/accounts_spec.rb @@ -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 diff --git a/spec/requests/api/v1/statuses_spec.rb b/spec/requests/api/v1/statuses_spec.rb index 6bba414f70..0b2d1f90cf 100644 --- a/spec/requests/api/v1/statuses_spec.rb +++ b/spec/requests/api/v1/statuses_spec.rb @@ -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