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,15 +23,23 @@ 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
expect(json).to match( before { post api_playlists_path, format: :json, playlist: playlist }
playlist: {
id: an_instance_of(Fixnum), it 'reponds with created status' do
name: playlist[:name] expect(response).to have_http_status 201
} end
)
it 'returns the playlist' do
expect(json).to match(
playlist: {
id: an_instance_of(Fixnum),
name: playlist[:name]
}
)
end
end end
it 'updates a playlist' do it 'updates a playlist' do