mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-11-15 09:21:25 +00:00
Return null steam data for previously invalid SteamIDs
This commit is contained in:
parent
798484af96
commit
f3c7942501
2 changed files with 4 additions and 6 deletions
2
app/controllers/api/v1/users_controller.rb
Normal file → Executable file
2
app/controllers/api/v1/users_controller.rb
Normal file → Executable file
|
@ -14,7 +14,7 @@ class Api::V1::UsersController < Api::V1::BaseController
|
|||
time_zone: @user.time_zone,
|
||||
avatar: @user.profile.avatar.url,
|
||||
admin: @user.admin?,
|
||||
steam: {
|
||||
steam: @user.steamid.nil? ? nil : {
|
||||
id: @user.steamid,
|
||||
url: @steam.nil? ? nil : @steam.base_url,
|
||||
nickname: @steam.nil? ? nil : @steam.nickname
|
||||
|
|
8
spec/controllers/api/v1/users_controller_spec.rb
Normal file → Executable file
8
spec/controllers/api/v1/users_controller_spec.rb
Normal file → Executable file
|
@ -29,16 +29,14 @@ describe Api::V1::UsersController do
|
|||
expect(json["team"]).to be_nil
|
||||
end
|
||||
|
||||
it "returns data for users with invalid steam ids" do
|
||||
@user.steamid = "0:0:000"
|
||||
it "returns nulled steam data for users who had invalid steam ids" do
|
||||
@user.steamid = nil
|
||||
@user.save!
|
||||
|
||||
get :show, id: @user.id
|
||||
|
||||
expect(response).to be_success
|
||||
expect(json["steam"]["id"]).to_not be_nil
|
||||
expect(json["steam"]["url"]).to be_nil
|
||||
expect(json["steam"]["nickname"]).to be_nil
|
||||
expect(json["steam"]).to be_nil
|
||||
end
|
||||
|
||||
it "returns 404 if user does not exist" do
|
||||
|
|
Loading…
Reference in a new issue