Test returning unprocessable entity when match_score update fails
This commit is contained in:
parent
24ce5b7a62
commit
15e344fa2e
|
|
@ -34,7 +34,7 @@ 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
|
it 'updates the requested score' 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
|
@match_score.reload
|
||||||
|
|
@ -49,6 +49,20 @@ RSpec.describe MatchScoresController, type: :controller do
|
||||||
end
|
end
|
||||||
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
|
context 'as another user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
apply_authentication_headers_for create(:user)
|
apply_authentication_headers_for create(:user)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue