Return 201 Created in API playlists/create
This commit is contained in:
parent
7a28b01287
commit
77be82a19f
@ -12,7 +12,7 @@ module API
|
||||
def create
|
||||
@playlist = current_user.playlists.build playlist_params
|
||||
@playlist.save
|
||||
render :show
|
||||
render :show, status: :created
|
||||
end
|
||||
|
||||
def update
|
||||
|
@ -23,15 +23,23 @@ describe 'API playlists' do
|
||||
)
|
||||
end
|
||||
|
||||
it 'creates a playlist' do
|
||||
playlist = attributes_for :playlist
|
||||
post api_playlists_path, format: :json, playlist: playlist
|
||||
expect(json).to match(
|
||||
playlist: {
|
||||
id: an_instance_of(Fixnum),
|
||||
name: playlist[:name]
|
||||
}
|
||||
)
|
||||
describe 'playlists create' do
|
||||
let(:playlist) { attributes_for :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(
|
||||
playlist: {
|
||||
id: an_instance_of(Fixnum),
|
||||
name: playlist[:name]
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
it 'updates a playlist' do
|
||||
|
Loading…
x
Reference in New Issue
Block a user