Implement tracks/show in AP

This commit is contained in:
Thibault Jouan 2015-05-02 00:11:52 +00:00
parent aaca5bf1d9
commit 6001cd2e79
4 changed files with 19 additions and 1 deletions

View File

@ -3,5 +3,9 @@ module API
def index def index
@tracks = Track.all @tracks = Track.all
end end
def show
@track = Track.find(params[:id])
end
end end
end end

View File

@ -0,0 +1,4 @@
object @track
attribute :id
attribute :name

View File

@ -7,7 +7,7 @@ Rails.application.routes.draw do
resources :playlists, only: %i[index show create] resources :playlists, only: %i[index show create]
resources :sessions, only: :create resources :sessions, only: :create
resources :sounds, only: :show resources :sounds, only: :show
resources :tracks, only: :index resources :tracks, only: %i[index show]
match '*all', to: 'application#not_found', via: :all match '*all', to: 'application#not_found', via: :all
end end

View File

@ -20,4 +20,14 @@ describe 'API tracks' do
} }
] ]
end end
it 'shows a track' do
track = create :track
get api_track_path track, format: :json
expect(json).to match(
id: track.id,
name: track.name
)
end
end end