Return new location in API playlists create

This commit is contained in:
Thibault Jouan 2015-05-04 03:41:28 +00:00
parent 4f11cc63e2
commit ef0b9053f1
2 changed files with 6 additions and 1 deletions

View File

@ -12,7 +12,7 @@ module API
def create
@playlist = current_user.playlists.build playlist_params
if @playlist.save
render :show, status: :created
render :show, status: :created, location: api_playlist_path(@playlist)
else
render json: @playlist.errors, status: :unprocessable_entity
end

View File

@ -41,6 +41,11 @@ describe 'API playlists' do
)
end
it 'creates the playlist' do
get response.location, format: :json
expect(json[:playlist]).to include playlist
end
context 'when playlist is invalid' do
let(:playlist) { attributes_for :playlist, name: '' }