Return error in JSON for users API

This commit is contained in:
Prommah 2017-09-30 14:35:27 +02:00 committed by Absurdon
parent 56087b09f3
commit 8717173797
2 changed files with 3 additions and 1 deletions

View file

@ -51,7 +51,7 @@ class Api::V1::UsersController < Api::V1::BaseController
private private
def not_found def not_found
head :not_found render json: {error: "User not found"}, status: :not_found
end end
def steam_profile(user) def steam_profile(user)

View file

@ -80,11 +80,13 @@ describe Api::V1::UsersController do
it "returns 404 if user does not exist" do it "returns 404 if user does not exist" do
get :show, id: -1 get :show, id: -1
expect(response.status).to eq(404) 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
get :show, id: -1, format: "steamid" get :show, id: -1, format: "steamid"
expect(response.status).to eq(404) 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