Implement ping/pong endpoint in API
This commit is contained in:
parent
cbacdd9fc1
commit
c0b2621b2f
@ -21,6 +21,10 @@ module API
|
|||||||
head :ok
|
head :ok
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def ping
|
||||||
|
render json: { pong: 'ok' }
|
||||||
|
end
|
||||||
|
|
||||||
def authenticate!
|
def authenticate!
|
||||||
head :unauthorized if current_user.nil?
|
head :unauthorized if current_user.nil?
|
||||||
end
|
end
|
||||||
|
@ -2,6 +2,7 @@ Rails.application.routes.draw do
|
|||||||
root 'home#index'
|
root 'home#index'
|
||||||
|
|
||||||
namespace :api do
|
namespace :api do
|
||||||
|
get '/ping' => 'application#ping'
|
||||||
resources :sounds, only: [:show]
|
resources :sounds, only: [:show]
|
||||||
resources :tracks, only: [:index]
|
resources :tracks, only: [:index]
|
||||||
resources :playlists, only: [:index, :create]
|
resources :playlists, only: [:index, :create]
|
||||||
|
13
spec/integration/api/application_spec.rb
Normal file
13
spec/integration/api/application_spec.rb
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
describe 'API application' do
|
||||||
|
include AcceptanceHelpers
|
||||||
|
|
||||||
|
before { api_sign_in }
|
||||||
|
|
||||||
|
describe 'ping endpoint' do
|
||||||
|
before { get api_ping_path, format: json }
|
||||||
|
|
||||||
|
it 'responds with a pong' do
|
||||||
|
expect(json).to eq({ pong: 'ok' })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user