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