Return 201 Created in API playlists/create

This commit is contained in:
Thibault Jouan 2015-05-04 00:53:42 +00:00
parent 7a28b01287
commit 77be82a19f
2 changed files with 18 additions and 10 deletions

View File

@ -12,7 +12,7 @@ module API
def create def create
@playlist = current_user.playlists.build playlist_params @playlist = current_user.playlists.build playlist_params
@playlist.save @playlist.save
render :show render :show, status: :created
end end
def update def update

View File

@ -23,9 +23,16 @@ describe 'API playlists' do
) )
end end
it 'creates a playlist' do describe 'playlists create' do
playlist = attributes_for :playlist let(:playlist) { attributes_for :playlist }
post api_playlists_path, format: :json, playlist: playlist
before { post api_playlists_path, format: :json, playlist: playlist }
it 'reponds with created status' do
expect(response).to have_http_status 201
end
it 'returns the playlist' do
expect(json).to match( expect(json).to match(
playlist: { playlist: {
id: an_instance_of(Fixnum), id: an_instance_of(Fixnum),
@ -33,6 +40,7 @@ describe 'API playlists' do
} }
) )
end end
end
it 'updates a playlist' do it 'updates a playlist' do
playlist = create :playlist playlist = create :playlist