diff --git a/config/routes.rb b/config/routes.rb index d1c4b6a..cd589ee 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,107 +1,118 @@ Rails.application.routes.draw do root 'application#index' get 'faq' => 'application#faq' post 'grnet' => 'application#grnet' get 'institutional' => 'application#institutional' match 'vima', to: 'application#vima', :via => [:get, :post] get 'logout' => 'application#logout' resources :clients, only: [:index, :show] do member do get :jobs get :logs get :stats post :stats get :users get :restore post :run_restore post :restore_selected delete :remove_user end collection do post :index end end resources :clients, only: [], param: :client_id do member do get :tree end end resources :invitations, only: [:create] get '/invitations/:host_id/:verification_code/accept' => 'invitations#accept', as: :accept_invitation resources :hosts, only: [:new, :create, :show, :edit, :update, :destroy] do member do post :submit_config post :disable delete :revoke end collection do get :fetch_vima_hosts, to: 'hosts#fetch_vima_hosts', as: :fetch_vima end resources :jobs, only: [:new, :create, :show, :edit, :update, :destroy] do member do patch :toggle_enable post :backup_now end end resources :filesets, only: [:show, :new, :create, :edit, :update, :destroy] resources :schedules, only: [:show, :new, :edit, :create, :update, :destroy] end namespace :admin do match '/', to: 'base#index', via: [:get, :post] get '/login' => 'base#login', as: :login resources :settings, only: [:index, :new, :create, :edit, :update] do member do delete :reset end end resources :clients, only: [:index, :show] do member do get :jobs get :logs get :stats post :stats get :configuration post :disable post :block post :unblock delete :revoke end end resources :hosts, only: [] do collection do get :unverified end member do post :verify put :set_quota end end resources :users, only: [:index, :new, :create, :show, :edit, :update] do member do patch :ban patch :unban end end resources :pools, only: [:index, :new, :create] resources :faqs end + + namespace :api, defaults: { format: :json } do + scope module: :v1, constraints: ApiVersion.new(version: 1, default: true) do + resources :clients, only: [:index, :show] do + member do + post :backup + post :restore + end + end + end + end end diff --git a/spec/routing/api/v1/client_routing_spec.rb b/spec/routing/api/v1/client_routing_spec.rb new file mode 100644 index 0000000..5057e4a --- /dev/null +++ b/spec/routing/api/v1/client_routing_spec.rb @@ -0,0 +1,21 @@ +require 'spec_helper' + +describe Api::V1::ClientsController do + it 'routes GET /api/clients' do + expect(get('/api/clients')). + to route_to(controller: 'api/v1/clients', action: 'index', format: :json) + end + + it 'routes GET /api/clients/:id' do + expect(get('/api/clients/1')). + to route_to(controller: 'api/v1/clients', action: 'show', id: '1', format: :json) + end + it 'routes POST /api/clients/:id/backup' do + expect(post('/api/clients/1/backup')). + to route_to(controller: 'api/v1/clients', action: 'backup', id: '1', format: :json) + end + it 'routes POST /api/clients/:id/restore' do + expect(post('/api/clients/1/restore')). + to route_to(controller: 'api/v1/clients', action: 'restore', id: '1', format: :json) + end +end