add gem api-pie
Error : stack level too deep
This commit is contained in:
parent
b4007c2735
commit
2a6da54320
9 changed files with 113 additions and 34 deletions
3
Gemfile
3
Gemfile
|
@ -79,6 +79,9 @@ gem 'bootstrap-wysihtml5-rails', '~> 0.3.3.8'
|
|||
|
||||
gem 'as_csv'
|
||||
|
||||
gem 'apipie-rails', '=0.3.1'
|
||||
gem "maruku" # for Markdown support in apipie
|
||||
|
||||
group :test do
|
||||
gem 'capybara'
|
||||
gem 'factory_girl'
|
||||
|
|
|
@ -47,6 +47,8 @@ GEM
|
|||
thread_safe (~> 0.3, >= 0.3.4)
|
||||
tzinfo (~> 1.1)
|
||||
addressable (2.3.8)
|
||||
apipie-rails (0.3.1)
|
||||
json
|
||||
arel (6.0.2)
|
||||
as_csv (2.0.2)
|
||||
actionpack (>= 3.0)
|
||||
|
@ -211,6 +213,7 @@ GEM
|
|||
activesupport (>= 3.1.0)
|
||||
rack (>= 1.4.0)
|
||||
rest-client
|
||||
maruku (0.7.2)
|
||||
method_source (0.8.2)
|
||||
mime-types (2.6.1)
|
||||
mini_portile (0.6.2)
|
||||
|
@ -453,6 +456,7 @@ PLATFORMS
|
|||
|
||||
DEPENDENCIES
|
||||
active_model_serializers
|
||||
apipie-rails (= 0.3.1)
|
||||
as_csv
|
||||
bootstrap-datepicker-rails
|
||||
bootstrap-sass (~> 3.3.5)
|
||||
|
@ -480,6 +484,7 @@ DEPENDENCIES
|
|||
leaflet-rails
|
||||
logstasher
|
||||
mailjet
|
||||
maruku
|
||||
mina!
|
||||
nyan-cat-formatter
|
||||
openid_connect
|
||||
|
|
|
@ -1,5 +1,18 @@
|
|||
class API::V1::DossiersController < APIController
|
||||
|
||||
api :GET, '/procedures/:procedure_id/dossiers/', 'Liste de tous les dossiers d\'une procédure'
|
||||
param :procedure_id, Integer, desc: "L'identifiant de la procédure", required: true
|
||||
error code: 401, desc: "Non authorisé"
|
||||
error code: 404, desc: "Procédure inconnue"
|
||||
|
||||
description <<-EOS
|
||||
Plop
|
||||
EOS
|
||||
|
||||
meta champs: {
|
||||
|
||||
}
|
||||
|
||||
def index
|
||||
procedure = current_administrateur.procedures.find(params[:procedure_id])
|
||||
dossiers = procedure.dossiers.where.not(state: :draft).paginate(page: params[:page])
|
||||
|
@ -8,6 +21,20 @@ class API::V1::DossiersController < APIController
|
|||
render json: {}, status: 404
|
||||
end
|
||||
|
||||
api :GET, '/procedures/:procedure_id/dossiers/:id', 'Informations du dossier d\'une procédure'
|
||||
param :procedure_id, Integer, desc: "L'identifiant de la procédure", required: true
|
||||
param :dossier_id, Integer, desc: "L'identifiant de la procédure", required: true
|
||||
error code: 401, desc: "Non authorisé"
|
||||
error code: 404, desc: "Procédure ou dossier inconnu"
|
||||
|
||||
description <<-EOS
|
||||
Plop
|
||||
EOS
|
||||
|
||||
meta champs: {
|
||||
|
||||
}
|
||||
|
||||
def show
|
||||
procedure = current_administrateur.procedures.find(params[:procedure_id])
|
||||
dossier = procedure.dossiers.find(params[:id])
|
||||
|
|
|
@ -1,4 +1,17 @@
|
|||
class API::V1::ProceduresController < APIController
|
||||
api :GET, '/procedures/:id', 'Informations concernant une procédure'
|
||||
param :id, Integer, desc: "L'identifiant de la procédure", required: true
|
||||
error code: 401, desc: "Non authorisé"
|
||||
error code: 404, desc: "Procédure inconnue"
|
||||
|
||||
description <<-EOS
|
||||
Plop
|
||||
EOS
|
||||
|
||||
meta champs: {
|
||||
|
||||
}
|
||||
|
||||
def show
|
||||
@procedure = current_administrateur.procedures.find(params[:id]).decorate
|
||||
|
||||
|
|
18
config/initializers/apipie.rb
Normal file
18
config/initializers/apipie.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
Apipie.configure do |config|
|
||||
config.app_name = "API TPS"
|
||||
config.api_base_url = "/api/v1"
|
||||
config.doc_base_url = "/docs"
|
||||
config.api_controllers_matcher = File.join(Rails.root, "app", "controllers","api","v1", "**","*.rb")
|
||||
config.markup = Apipie::Markup::Markdown.new
|
||||
config.default_version = '1.0'
|
||||
config.validate = false
|
||||
config.copyright = "© SGMAP"
|
||||
config.namespaced_resources = true
|
||||
config.show_all_examples = true
|
||||
|
||||
config.app_info = <<-EOS
|
||||
Description
|
||||
|
||||
EOS
|
||||
|
||||
end
|
|
@ -113,4 +113,6 @@ Rails.application.routes.draw do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
apipie
|
||||
end
|
||||
|
|
|
@ -28,7 +28,9 @@ describe API::V1::DossiersController do
|
|||
let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') } }
|
||||
let(:body) { JSON.parse(response.body, symbolize_names: true) }
|
||||
|
||||
it { expect(response.code).to eq('200') }
|
||||
it 'return REST code 200', :show_in_doc do
|
||||
expect(response.code).to eq('200')
|
||||
end
|
||||
|
||||
it { expect(body).to have_key :pagination }
|
||||
|
||||
|
@ -117,7 +119,9 @@ describe API::V1::DossiersController do
|
|||
let(:field_list) { [:id, :nom_projet, :created_at, :updated_at, :description, :archived, :entreprise, :etablissement] }
|
||||
subject { body[:dossier] }
|
||||
|
||||
it { expect(response.code).to eq('200') }
|
||||
it 'return REST code 200', :show_in_doc do
|
||||
expect(response.code).to eq('200')
|
||||
end
|
||||
it { expect(subject[:id]).to eq(dossier.id) }
|
||||
it { expect(subject[:nom_projet]).to eq(dossier.nom_projet) }
|
||||
it { expect(subject[:created_at]).to eq('2008-09-01T08:05:00.000Z') }
|
||||
|
@ -140,12 +144,12 @@ describe API::V1::DossiersController do
|
|||
:date_creation,
|
||||
:nom,
|
||||
:prenom] }
|
||||
subject { super()[:entreprise]}
|
||||
subject { super()[:entreprise] }
|
||||
|
||||
it { expect(subject[:siren]).to eq('440117620')}
|
||||
it { expect(subject[:capital_social]).to eq(537_100_000)}
|
||||
it { expect(subject[:numero_tva_intracommunautaire]).to eq('FR27440117620')}
|
||||
it { expect(subject[:forme_juridique]).to eq('SA à conseil d\'administration (s.a.i.)')}
|
||||
it { expect(subject[:siren]).to eq('440117620') }
|
||||
it { expect(subject[:capital_social]).to eq(537_100_000) }
|
||||
it { expect(subject[:numero_tva_intracommunautaire]).to eq('FR27440117620') }
|
||||
it { expect(subject[:forme_juridique]).to eq('SA à conseil d\'administration (s.a.i.)') }
|
||||
it { expect(subject[:forme_juridique_code]).to eq('5599') }
|
||||
it { expect(subject[:nom_commercial]).to eq('GRTGAZ') }
|
||||
it { expect(subject[:raison_sociale]).to eq('GRTGAZ') }
|
||||
|
@ -170,7 +174,7 @@ describe API::V1::DossiersController do
|
|||
:localite,
|
||||
:code_insee_localite
|
||||
] }
|
||||
subject { super()[:etablissement]}
|
||||
subject { super()[:etablissement] }
|
||||
|
||||
it { expect(subject[:siret]).to eq('44011762001530') }
|
||||
it { expect(subject[:siege_social]).to eq(true) }
|
||||
|
|
|
@ -3,6 +3,7 @@ require 'spec_helper'
|
|||
describe API::V1::ProceduresController do
|
||||
let(:admin) { create(:administrateur) }
|
||||
it { expect(described_class).to be < APIController }
|
||||
|
||||
describe 'GET show' do
|
||||
context 'when procedure does not exist' do
|
||||
subject { get :show, id: 999_999_999, token: admin.api_token }
|
||||
|
@ -16,9 +17,13 @@ describe API::V1::ProceduresController do
|
|||
context 'when procedure exist' do
|
||||
let(:procedure) { create(:procedure, administrateur: admin) }
|
||||
subject { get :show, id: procedure, token: admin.api_token }
|
||||
it { expect(subject.status).to eq(200) }
|
||||
|
||||
it 'return REST code 200', :show_in_doc do
|
||||
expect(subject.status).to eq(200)
|
||||
end
|
||||
|
||||
describe 'body' do
|
||||
let(:module_api_carto) { create(:module_api_carto, use_api_carto: true, quartiers_prioritaires: true, cadastre: true)}
|
||||
let(:module_api_carto) { create(:module_api_carto, use_api_carto: true, quartiers_prioritaires: true, cadastre: true) }
|
||||
let(:procedure) { create(:procedure, :with_type_de_champ, :with_two_type_de_piece_justificative, module_api_carto: module_api_carto, administrateur: admin) }
|
||||
let(:response) { get :show, id: procedure.id, token: admin.api_token }
|
||||
subject { JSON.parse(response.body, symbolize_names: true)[:procedure] }
|
||||
|
|
|
@ -80,6 +80,8 @@ RSpec.configure do |config|
|
|||
|
||||
config.infer_base_class_for_anonymous_controllers = false
|
||||
|
||||
config.filter_run :show_in_doc => true if ENV['APIPIE_RECORD']
|
||||
|
||||
config.order = 'random'
|
||||
|
||||
config.include Devise::TestHelpers, type: :view
|
||||
|
|
Loading…
Reference in a new issue