Return 422 when API playlists cannot be saved
This commit is contained in:
parent
dcfe1b1b79
commit
8f8cdaec79
@ -11,8 +11,11 @@ module API
|
|||||||
|
|
||||||
def create
|
def create
|
||||||
@playlist = current_user.playlists.build playlist_params
|
@playlist = current_user.playlists.build playlist_params
|
||||||
@playlist.save
|
if @playlist.save
|
||||||
render :show, status: :created
|
render :show, status: :created
|
||||||
|
else
|
||||||
|
render json: :nothing, status: :unprocessable_entity
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
@ -40,6 +40,14 @@ describe 'API playlists' do
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when playlist is invalid' do
|
||||||
|
let(:playlist) { attributes_for :playlist, name: '' }
|
||||||
|
|
||||||
|
it 'responds with unprocessable entity status' do
|
||||||
|
expect(response).to have_http_status 422
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'updates a playlist' do
|
it 'updates a playlist' do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user