Add "simple" parameter to tournament show
This commit is contained in:
parent
46c903e109
commit
d317585168
|
|
@ -25,7 +25,11 @@ class TournamentsController < ApplicationController
|
||||||
|
|
||||||
# GET /tournaments/1
|
# GET /tournaments/1
|
||||||
def show
|
def show
|
||||||
render json: @tournament, include: '**'
|
if show_params.fetch(:simple, 'false') == 'true'
|
||||||
|
render json: @tournament, serializer: SimpleTournamentSerializer
|
||||||
|
else
|
||||||
|
render json: @tournament, include: '**'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# POST /tournaments
|
# POST /tournaments
|
||||||
|
|
@ -116,6 +120,10 @@ class TournamentsController < ApplicationController
|
||||||
params.permit(:type)
|
params.permit(:type)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def show_params
|
||||||
|
params.permit(:simple)
|
||||||
|
end
|
||||||
|
|
||||||
def tournament_params
|
def tournament_params
|
||||||
params.slice(:name, :description, :public, :teams, :group_stage, :playoff_teams_amount).permit!
|
params.slice(:name, :description, :public, :teams, :group_stage, :playoff_teams_amount).permit!
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,15 @@ RSpec.describe TournamentsController, type: :controller do
|
||||||
get :show, params: { id: @tournament.to_param }
|
get :show, params: { id: @tournament.to_param }
|
||||||
expect(deserialize_response(response)[:id].to_i).to eq(@tournament.id)
|
expect(deserialize_response(response)[:id].to_i).to eq(@tournament.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with simple=true parameter' do
|
||||||
|
it 'returns no relations' do
|
||||||
|
get :show, params: { id: @tournament.to_param, simple: 'true' }
|
||||||
|
body = deserialize_response response
|
||||||
|
expect(body[:stages]).to be_nil
|
||||||
|
expect(body[:teams]).to be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'POST #create' do
|
describe 'POST #create' do
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue