Test unprocessable entity response on a match that is not ready
Unprocessable entity is returned when you try to start a match that is not ready yet.
This commit is contained in:
parent
d03ceeffa4
commit
41b8bdce77
|
|
@ -8,6 +8,7 @@ RSpec.describe MatchesController, type: :controller do
|
||||||
@amount_of_stages = 2
|
@amount_of_stages = 2
|
||||||
@tournament = create(:stage_tournament, stage_count: @amount_of_stages)
|
@tournament = create(:stage_tournament, stage_count: @amount_of_stages)
|
||||||
@running_playoff_match = @tournament.stages.find_by(level: @amount_of_stages).matches.first
|
@running_playoff_match = @tournament.stages.find_by(level: @amount_of_stages).matches.first
|
||||||
|
@not_ready_playoff_match = create(:running_playoff_match, state: :not_ready)
|
||||||
@match.match_scores = create_pair(:match_score)
|
@match.match_scores = create_pair(:match_score)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -188,5 +189,26 @@ RSpec.describe MatchesController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'on a playoff match that isn\'t ready yet' do
|
||||||
|
let(:invalid_update) do
|
||||||
|
{
|
||||||
|
state: 'in_progress'
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'as owner' do
|
||||||
|
before(:each) do
|
||||||
|
apply_authentication_headers_for @not_ready_playoff_match.owner
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with invalid params' do
|
||||||
|
it 'renders an unprocessable entity response' do
|
||||||
|
put :update, params: { id: @not_ready_playoff_match.to_param }.merge(invalid_update)
|
||||||
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue