diff --git a/app/controllers/api/application_controller.rb b/app/controllers/api/application_controller.rb index d8a77e7..bf9073d 100644 --- a/app/controllers/api/application_controller.rb +++ b/app/controllers/api/application_controller.rb @@ -21,6 +21,10 @@ module API head :ok end + def ping + render json: { pong: 'ok' } + end + def authenticate! head :unauthorized if current_user.nil? end diff --git a/config/routes.rb b/config/routes.rb index 3feef6c..7d481a1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,6 +2,7 @@ Rails.application.routes.draw do root 'home#index' namespace :api do + get '/ping' => 'application#ping' resources :sounds, only: [:show] resources :tracks, only: [:index] resources :playlists, only: [:index, :create] diff --git a/spec/integration/api/application_spec.rb b/spec/integration/api/application_spec.rb new file mode 100644 index 0000000..e3ef245 --- /dev/null +++ b/spec/integration/api/application_spec.rb @@ -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