From e6f05374d3fa0794065852b5a58f7560284c4abe Mon Sep 17 00:00:00 2001 From: Chris Blanchard Date: Mon, 17 Aug 2015 18:55:03 +0100 Subject: [PATCH] Added id to users API index method --- app/services/api/v1/users_collection.rb | 4 +++- spec/controllers/api/v1/users_controller_spec.rb | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/services/api/v1/users_collection.rb b/app/services/api/v1/users_collection.rb index 8065d41..2630913 100644 --- a/app/services/api/v1/users_collection.rb +++ b/app/services/api/v1/users_collection.rb @@ -29,7 +29,8 @@ class Api::V1::UsersCollection < Api::V1::Collection users_table[:steamid], teams_table[:name], teams_table[:tag], - teams_table[:logo] + teams_table[:logo], + users_table[:id] ] end @@ -45,6 +46,7 @@ class Api::V1::UsersCollection < Api::V1::Collection def map_query execute_query.map do |row| { + id: row[5], username: row[0], steamid: row[1], team: { diff --git a/spec/controllers/api/v1/users_controller_spec.rb b/spec/controllers/api/v1/users_controller_spec.rb index 72b42ab..3a8d07e 100644 --- a/spec/controllers/api/v1/users_controller_spec.rb +++ b/spec/controllers/api/v1/users_controller_spec.rb @@ -81,11 +81,11 @@ describe Api::V1::UsersController do it 'returns the excpected JSON keys' do get :index - user_json = json["users"].first nested_team_json = user_json["team"] expect(user_json).to have_key("username") + expect(user_json).to have_key("id") expect(user_json).to have_key("steamid") expect(user_json).to have_key("team") expect(nested_team_json).to have_key("name")