Test returning unprocessable entity when match_score update fails
This commit is contained in:
parent
41f5295a50
commit
c9c47fa0e5
|
|
@ -34,7 +34,7 @@ RSpec.describe MatchScoresController, type: :controller do
|
|||
before(:each) do
|
||||
apply_authentication_headers_for @owner
|
||||
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
|
||||
|
|
@ -49,6 +49,20 @@ RSpec.describe MatchScoresController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when match_score update fails' do
|
||||
before do
|
||||
allow_any_instance_of(MatchScore)
|
||||
.to receive(:update)
|
||||
.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
|
||||
|
||||
context 'as another user' do
|
||||
before(:each) do
|
||||
apply_authentication_headers_for create(:user)
|
||||
|
|
|
|||
Loading…
Reference in New Issue