Test returning unprocessable entity when match_score update fails
This commit is contained in:
parent
24ce5b7a62
commit
15e344fa2e
|
|
@ -34,18 +34,32 @@ RSpec.describe MatchScoresController, type: :controller do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
apply_authentication_headers_for @owner
|
apply_authentication_headers_for @owner
|
||||||
end
|
end
|
||||||
|
context 'when match_score update succeeds' do
|
||||||
|
it 'updates the requested score' do
|
||||||
|
put :update, params: { id: @match_score.to_param }.merge(valid_update)
|
||||||
|
@match_score.reload
|
||||||
|
expect(@match_score.points).to eq(valid_update[:points])
|
||||||
|
end
|
||||||
|
|
||||||
it 'updates the requested score' do
|
it 'renders a response with the updated team' do
|
||||||
put :update, params: { id: @match_score.to_param }.merge(valid_update)
|
put :update, params: { id: @match_score.to_param }.merge(valid_update)
|
||||||
@match_score.reload
|
expect(response).to be_successful
|
||||||
expect(@match_score.points).to eq(valid_update[:points])
|
body = deserialize_response response
|
||||||
|
expect(body[:points]).to eq(valid_update[:points])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'renders a response with the updated team' do
|
context 'when match_score update fails' do
|
||||||
put :update, params: { id: @match_score.to_param }.merge(valid_update)
|
before do
|
||||||
expect(response).to be_successful
|
allow_any_instance_of(MatchScore)
|
||||||
body = deserialize_response response
|
.to receive(:update)
|
||||||
expect(body[:points]).to eq(valid_update[:points])
|
.and_return(false)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns unprocessable entity' do
|
||||||
|
put :update, params: { id: @match_score.to_param }.merge(valid_update)
|
||||||
|
expect(response).to have_http_status(:unprocessable_entity)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue