mirror of
https://github.com/ENSL/ensl.org.git
synced 2025-01-13 21:31:28 +00:00
commit
7b76f4fe36
3 changed files with 31 additions and 1 deletions
|
@ -8,6 +8,12 @@ class Api::V1::UsersController < Api::V1::BaseController
|
|||
@steam = SteamCondenser::Community::SteamId.from_steam_id("STEAM_#{@user.steamid}")
|
||||
|
||||
render json: {
|
||||
id: @user.id,
|
||||
username: @user.username,
|
||||
country: @user.country,
|
||||
time_zone: @user.time_zone,
|
||||
avatar: @user.profile.avatar.url,
|
||||
admin: @user.admin?,
|
||||
steam: {
|
||||
url: @steam.base_url,
|
||||
nickname: @steam.nickname
|
||||
|
|
|
@ -5,9 +5,29 @@ describe Api::V1::UsersController do
|
|||
request.accept = 'application/json'
|
||||
end
|
||||
|
||||
describe '#show' do
|
||||
before do
|
||||
@user = create :user_with_team, :chris
|
||||
end
|
||||
|
||||
it 'returns user data' do
|
||||
get :show, id: @user.id
|
||||
|
||||
expect(response).to be_success
|
||||
expect(json['id']).to eq(@user.id)
|
||||
expect(json['username']).to eq(@user.username)
|
||||
expect(json['country']).to eq(@user.country)
|
||||
expect(json['time_zone']).to eq(@user.time_zone)
|
||||
expect(json['admin']).to eq(@user.admin?)
|
||||
expect(json).to have_key("steam")
|
||||
expect(json['steam']).to have_key("url")
|
||||
expect(json['steam']).to have_key("nickname")
|
||||
end
|
||||
end
|
||||
|
||||
describe '#index' do
|
||||
before do
|
||||
10.times { create(:user_with_team) }
|
||||
5.times { create(:user_with_team) }
|
||||
end
|
||||
|
||||
it 'returns all users and associated teams' do
|
||||
|
|
|
@ -20,6 +20,10 @@ FactoryGirl.define do
|
|||
end
|
||||
end
|
||||
|
||||
trait :chris do
|
||||
steamid "0:1:58097444"
|
||||
end
|
||||
|
||||
factory :user_with_team do
|
||||
after(:create) do |user|
|
||||
create(:team, founder: user)
|
||||
|
|
Loading…
Reference in a new issue