diff options
| author | Xinhui | 2017-08-22 12:49:55 +0200 | 
|---|---|---|
| committer | Xinhui | 2017-08-22 14:52:49 +0200 | 
| commit | 9a281154ea20a6450bb53880f1dd77d5139075f1 (patch) | |
| tree | a9dd7c08bd500ed0f9238c0b1c5038d9cef22ec9 | |
| parent | 49eeb2919090f26f5d16d446df6f5890fc71625a (diff) | |
| download | chouette-core-9a281154ea20a6450bb53880f1dd77d5139075f1.tar.bz2 | |
API - new end point for workbenches
| -rw-r--r-- | app/controllers/api/v1/chouette_controller.rb | 5 | ||||
| -rw-r--r-- | app/controllers/api/v1/workbenches_controller.rb | 3 | ||||
| -rw-r--r-- | app/controllers/api_keys_controller.rb | 2 | ||||
| -rw-r--r-- | app/views/api/v1/workbenches/index.rabl | 3 | ||||
| -rw-r--r-- | app/views/api/v1/workbenches/show.rabl | 3 | ||||
| -rw-r--r-- | config/routes.rb | 1 | ||||
| -rw-r--r-- | spec/controllers/api/v1/workbenches_controller_spec.rb | 5 | 
7 files changed, 18 insertions, 4 deletions
| diff --git a/app/controllers/api/v1/chouette_controller.rb b/app/controllers/api/v1/chouette_controller.rb index 7805074ee..98c2fff05 100644 --- a/app/controllers/api/v1/chouette_controller.rb +++ b/app/controllers/api/v1/chouette_controller.rb @@ -7,7 +7,6 @@ module Api        before_action :authenticate        private -        def authenticate          authenticate_or_request_with_http_token do |token, options|            @referential = Api::V1::ApiKey.referential_from_token(token) @@ -16,10 +15,10 @@ module Api            switch_referential if @api_key          end        end +        def switch_referential          Apartment::Tenant.switch!(@api_key.referential.slug) -      end  - +      end      end    end  end diff --git a/app/controllers/api/v1/workbenches_controller.rb b/app/controllers/api/v1/workbenches_controller.rb new file mode 100644 index 000000000..3c07997ce --- /dev/null +++ b/app/controllers/api/v1/workbenches_controller.rb @@ -0,0 +1,3 @@ +class Api::V1::WorkbenchesController < Api::V1::IbooController +  defaults :resource_class => Workbench +end diff --git a/app/controllers/api_keys_controller.rb b/app/controllers/api_keys_controller.rb index bd225818b..7059cf52e 100644 --- a/app/controllers/api_keys_controller.rb +++ b/app/controllers/api_keys_controller.rb @@ -3,7 +3,7 @@ class ApiKeysController < BreadcrumbController    def create      @api_key = Api::V1::ApiKey.new(api_key_params.merge(organisation: current_organisation)) -    create! { organisation_api_key_path(resource) } +    create! { organisation_api_keys_path }    end    def index diff --git a/app/views/api/v1/workbenches/index.rabl b/app/views/api/v1/workbenches/index.rabl new file mode 100644 index 000000000..2f0bf5fee --- /dev/null +++ b/app/views/api/v1/workbenches/index.rabl @@ -0,0 +1,3 @@ +collection @workbenches + +extends "api/v1/workbenches/show" diff --git a/app/views/api/v1/workbenches/show.rabl b/app/views/api/v1/workbenches/show.rabl new file mode 100644 index 000000000..d43727809 --- /dev/null +++ b/app/views/api/v1/workbenches/show.rabl @@ -0,0 +1,3 @@ +object @workbench + +attributes :id, :name diff --git a/config/routes.rb b/config/routes.rb index ea0eefd06..43aec62ea 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -32,6 +32,7 @@ ChouetteIhm::Application.routes.draw do    namespace :api do      namespace :v1 do +      resources :workbenches, only: [:index, :show]        resources :access_links, only: [:index, :show]        resources :access_points, only: [:index, :show]        resources :connection_links, only: [:index, :show] diff --git a/spec/controllers/api/v1/workbenches_controller_spec.rb b/spec/controllers/api/v1/workbenches_controller_spec.rb new file mode 100644 index 000000000..187d8ffeb --- /dev/null +++ b/spec/controllers/api/v1/workbenches_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Api::V1::WorkbenchesController, type: :controller do + +end | 
