mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-11-15 01:11:23 +00:00
404 bad user API requests & spec
This commit is contained in:
parent
6b5cafcbf0
commit
56087b09f3
2 changed files with 10 additions and 4 deletions
|
@ -14,7 +14,7 @@ class Api::V1::UsersController < Api::V1::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
if @user.nil?
|
if @user.nil?
|
||||||
render json: nil, status: :not_found
|
not_found
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -45,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
|
||||||
|
head :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,13 @@ 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)
|
||||||
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)
|
||||||
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