Implement API playlists/destroy
This commit is contained in:
parent
d03007c99f
commit
689fe2f4dd
@ -1,6 +1,6 @@
|
||||
module API
|
||||
class PlaylistsController < ApplicationController
|
||||
before_action :set_playlist, only: %i[show update]
|
||||
before_action :set_playlist, only: %i[show update destroy]
|
||||
|
||||
def index
|
||||
@playlists = Playlist.all
|
||||
@ -19,6 +19,11 @@ module API
|
||||
head :no_content
|
||||
end
|
||||
|
||||
def destroy
|
||||
@playlist.destroy
|
||||
head :no_content
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
|
@ -4,7 +4,7 @@ Rails.application.routes.draw do
|
||||
namespace :api do
|
||||
get '/ping', to: 'application#ping'
|
||||
match '*all', to: 'application#cor_preflight', via: :options
|
||||
resources :playlists, only: %i[index show create update]
|
||||
resources :playlists, only: %i[index show create update destroy]
|
||||
resources :sessions, only: :create
|
||||
resources :sounds, only: :show
|
||||
resources :tracks, only: %i[index show]
|
||||
|
@ -44,4 +44,11 @@ describe 'API playlists' do
|
||||
name: 'new name'
|
||||
)
|
||||
end
|
||||
|
||||
it 'destroys a playlist' do
|
||||
playlist = create :playlist
|
||||
expect { delete api_playlist_path(playlist), format: :json }
|
||||
.to change { get api_playlist_path playlist, format: :json }
|
||||
.from(200).to 404
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user