From ef0b9053f13ee562f70a0feebb3767514cda2409 Mon Sep 17 00:00:00 2001 From: Thibault Jouan Date: Mon, 4 May 2015 03:41:28 +0000 Subject: [PATCH] Return new location in API playlists create --- app/controllers/api/playlists_controller.rb | 2 +- spec/integration/api/playlists_spec.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/playlists_controller.rb b/app/controllers/api/playlists_controller.rb index 90300c5..7f6db3e 100644 --- a/app/controllers/api/playlists_controller.rb +++ b/app/controllers/api/playlists_controller.rb @@ -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 diff --git a/spec/integration/api/playlists_spec.rb b/spec/integration/api/playlists_spec.rb index 2d7e6f9..b2b5e4b 100644 --- a/spec/integration/api/playlists_spec.rb +++ b/spec/integration/api/playlists_spec.rb @@ -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: '' }