mirror of
https://github.com/ENSL/ensl.org.git
synced 2025-02-09 17:51:23 +00:00
Merge branch 'master' into MatchScheduler
This commit is contained in:
commit
548b15489c
2 changed files with 13 additions and 4 deletions
|
@ -14,7 +14,8 @@ class Api::V1::UsersController < Api::V1::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
if @user.nil?
|
if @user.nil?
|
||||||
raise ActionController::RoutingError.new("User Not Found")
|
not_found
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if @user.steamid.present?
|
if @user.steamid.present?
|
||||||
|
@ -44,11 +45,15 @@ class Api::V1::UsersController < Api::V1::BaseController
|
||||||
team: @user.team.present? ? { id: @user.team.id, name: @user.team.name } : nil
|
team: @user.team.present? ? { id: @user.team.id, name: @user.team.name } : nil
|
||||||
}
|
}
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
raise ActionController::RoutingError.new("User Not Found")
|
not_found
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def not_found
|
||||||
|
render json: {error: "User not found"}, status: :not_found
|
||||||
|
end
|
||||||
|
|
||||||
def steam_profile(user)
|
def steam_profile(user)
|
||||||
SteamCondenser::Community::SteamId.from_steam_id("STEAM_#{user.steamid}")
|
SteamCondenser::Community::SteamId.from_steam_id("STEAM_#{user.steamid}")
|
||||||
rescue SteamCondenser::Error
|
rescue SteamCondenser::Error
|
||||||
|
|
|
@ -78,11 +78,15 @@ describe Api::V1::UsersController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns 404 if user does not exist" do
|
it "returns 404 if user does not exist" do
|
||||||
expect { get :show, id: -1 }.to raise_error(ActionController::RoutingError)
|
get :show, id: -1
|
||||||
|
expect(response.status).to eq(404)
|
||||||
|
expect(json["error"]).to eq("User not found")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns 404 if user does not exist by steamid" do
|
it "returns 404 if user does not exist by steamid" do
|
||||||
expect { get :show, id: -1, format: "steamid" }.to raise_error(ActionController::RoutingError)
|
get :show, id: -1, format: "steamid"
|
||||||
|
expect(response.status).to eq(404)
|
||||||
|
expect(json["error"]).to eq("User not found")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "queries the steam condenser for an invalid steamid" do
|
it "queries the steam condenser for an invalid steamid" do
|
||||||
|
|
Loading…
Reference in a new issue