Return new location in API playlists create
This commit is contained in:
parent
4f11cc63e2
commit
ef0b9053f1
@ -12,7 +12,7 @@ module API
|
|||||||
def create
|
def create
|
||||||
@playlist = current_user.playlists.build playlist_params
|
@playlist = current_user.playlists.build playlist_params
|
||||||
if @playlist.save
|
if @playlist.save
|
||||||
render :show, status: :created
|
render :show, status: :created, location: api_playlist_path(@playlist)
|
||||||
else
|
else
|
||||||
render json: @playlist.errors, status: :unprocessable_entity
|
render json: @playlist.errors, status: :unprocessable_entity
|
||||||
end
|
end
|
||||||
|
@ -41,6 +41,11 @@ describe 'API playlists' do
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'creates the playlist' do
|
||||||
|
get response.location, format: :json
|
||||||
|
expect(json[:playlist]).to include playlist
|
||||||
|
end
|
||||||
|
|
||||||
context 'when playlist is invalid' do
|
context 'when playlist is invalid' do
|
||||||
let(:playlist) { attributes_for :playlist, name: '' }
|
let(:playlist) { attributes_for :playlist, name: '' }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user