Test controller params as they're documented
This commit is contained in:
parent
9d914774a2
commit
667d6a028c
|
|
@ -36,13 +36,13 @@ RSpec.describe MatchScoresController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'updates the requested score' do
|
it 'updates the requested score' do
|
||||||
put :update, params: { id: @match_score.to_param, match_score: valid_update }
|
put :update, params: { id: @match_score.to_param }.merge(valid_update)
|
||||||
@match_score.reload
|
@match_score.reload
|
||||||
expect(@match_score.points).to eq(valid_update[:points])
|
expect(@match_score.points).to eq(valid_update[:points])
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'renders a response with the updated team' do
|
it 'renders a response with the updated team' do
|
||||||
put :update, params: { id: @match_score.to_param, match_score: valid_update }
|
put :update, params: { id: @match_score.to_param }.merge(valid_update)
|
||||||
expect(response).to be_successful
|
expect(response).to be_successful
|
||||||
body = deserialize_response response
|
body = deserialize_response response
|
||||||
expect(body[:points]).to eq(valid_update[:points])
|
expect(body[:points]).to eq(valid_update[:points])
|
||||||
|
|
@ -55,7 +55,7 @@ RSpec.describe MatchScoresController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'renders a forbidden error response' do
|
it 'renders a forbidden error response' do
|
||||||
put :update, params: { id: @match_score.to_param, match_score: valid_update }
|
put :update, params: { id: @match_score.to_param }.merge(valid_update)
|
||||||
expect(response).to have_http_status(:forbidden)
|
expect(response).to have_http_status(:forbidden)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -34,14 +34,14 @@ RSpec.describe TeamsController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'updates the requested team' do
|
it 'updates the requested team' do
|
||||||
put :update, params: { id: @team.to_param, team: valid_update }
|
put :update, params: { id: @team.to_param }.merge(valid_update)
|
||||||
@team.reload
|
@team.reload
|
||||||
expect(response).to be_successful
|
expect(response).to be_successful
|
||||||
expect(@team.name).to eq(valid_update[:name])
|
expect(@team.name).to eq(valid_update[:name])
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'renders a response with the updated team' do
|
it 'renders a response with the updated team' do
|
||||||
put :update, params: { id: @team.to_param, team: valid_update }
|
put :update, params: { id: @team.to_param }.merge(valid_update)
|
||||||
expect(response).to be_successful
|
expect(response).to be_successful
|
||||||
body = deserialize_response response
|
body = deserialize_response response
|
||||||
expect(body[:name]).to eq(valid_update[:name])
|
expect(body[:name]).to eq(valid_update[:name])
|
||||||
|
|
@ -54,7 +54,7 @@ RSpec.describe TeamsController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'renders a forbidden error response' do
|
it 'renders a forbidden error response' do
|
||||||
put :update, params: { id: @team.to_param, team: valid_update }
|
put :update, params: { id: @team.to_param }.merge(valid_update)
|
||||||
expect(response).to have_http_status(:forbidden)
|
expect(response).to have_http_status(:forbidden)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ RSpec.describe TournamentsController, type: :controller do
|
||||||
context 'with valid params' do
|
context 'with valid params' do
|
||||||
context 'without authentication headers' do
|
context 'without authentication headers' do
|
||||||
it 'renders a unauthorized error response' do
|
it 'renders a unauthorized error response' do
|
||||||
put :update, params: { id: @tournament.to_param, tournament: valid_update }
|
put :update, params: { id: @tournament.to_param }.merge(valid_update)
|
||||||
expect(response).to have_http_status(:unauthorized)
|
expect(response).to have_http_status(:unauthorized)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -127,13 +127,13 @@ RSpec.describe TournamentsController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'updates the requested tournament' do
|
it 'updates the requested tournament' do
|
||||||
put :update, params: { id: @tournament.to_param, tournament: valid_update }
|
put :update, params: { id: @tournament.to_param }.merge(valid_update)
|
||||||
@tournament.reload
|
@tournament.reload
|
||||||
expect(@tournament.name).to eq(valid_update[:name])
|
expect(@tournament.name).to eq(valid_update[:name])
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'renders a JSON response with the tournament' do
|
it 'renders a JSON response with the tournament' do
|
||||||
put :update, params: { id: @tournament.to_param, tournament: valid_update }
|
put :update, params: { id: @tournament.to_param }.merge(valid_update)
|
||||||
expect(response).to have_http_status(:ok)
|
expect(response).to have_http_status(:ok)
|
||||||
expect(response.content_type).to eq('application/json')
|
expect(response.content_type).to eq('application/json')
|
||||||
end
|
end
|
||||||
|
|
@ -145,7 +145,7 @@ RSpec.describe TournamentsController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'renders a forbidden error response' do
|
it 'renders a forbidden error response' do
|
||||||
put :update, params: { id: @tournament.to_param, tournament: valid_update }
|
put :update, params: { id: @tournament.to_param }.merge(valid_update)
|
||||||
expect(response).to have_http_status(:forbidden)
|
expect(response).to have_http_status(:forbidden)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue