mirror of
https://github.com/ENSL/ensl.org.git
synced 2025-05-30 08:20:45 +00:00
Added initial API endpoint to fetch basic user and associated team information.
This commit is contained in:
parent
722f2d87d7
commit
5a9c393791
14 changed files with 180 additions and 3 deletions
36
spec/controllers/api/v1/users_controller_spec.rb
Normal file
36
spec/controllers/api/v1/users_controller_spec.rb
Normal file
|
@ -0,0 +1,36 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Api::V1::UsersController do
|
||||
before do
|
||||
request.accept = 'application/json'
|
||||
end
|
||||
|
||||
describe '#index' do
|
||||
before do
|
||||
10.times { create(:user_with_team) }
|
||||
end
|
||||
|
||||
it 'returns all users and associated teams' do
|
||||
users = User.all
|
||||
|
||||
get :index
|
||||
|
||||
expect(response).to be_success
|
||||
expect(json["users"].size).to eq(users.size)
|
||||
end
|
||||
|
||||
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("steamid")
|
||||
expect(user_json).to have_key("team")
|
||||
expect(nested_team_json).to have_key("name")
|
||||
expect(nested_team_json).to have_key("tag")
|
||||
expect(nested_team_json).to have_key("logo")
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue