diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb old mode 100644 new mode 100755 index 161772b..7c992d2 --- a/app/controllers/api/v1/users_controller.rb +++ b/app/controllers/api/v1/users_controller.rb @@ -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 diff --git a/spec/controllers/api/v1/users_controller_spec.rb b/spec/controllers/api/v1/users_controller_spec.rb old mode 100644 new mode 100755 index f9e362b..c2a7059 --- a/spec/controllers/api/v1/users_controller_spec.rb +++ b/spec/controllers/api/v1/users_controller_spec.rb @@ -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