Implement tracks/show in AP
This commit is contained in:
parent
aaca5bf1d9
commit
6001cd2e79
@ -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
|
||||||
|
4
app/views/api/tracks/show.rabl
Normal file
4
app/views/api/tracks/show.rabl
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
object @track
|
||||||
|
|
||||||
|
attribute :id
|
||||||
|
attribute :name
|
@ -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
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user