add module api carto in api procedure
This commit is contained in:
parent
3ea381413f
commit
c04627431c
4 changed files with 29 additions and 6 deletions
|
@ -9,4 +9,7 @@ class ProcedureDecorator < Draper::Decorator
|
||||||
return 'logo-tps.png' if logo.blank?
|
return 'logo-tps.png' if logo.blank?
|
||||||
logo
|
logo
|
||||||
end
|
end
|
||||||
|
def geographic_information
|
||||||
|
module_api_carto
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
7
app/serializers/module_api_carto_serializer.rb
Normal file
7
app/serializers/module_api_carto_serializer.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
class ModuleApiCartoSerializer < ActiveModel::Serializer
|
||||||
|
attributes :use_api_carto,
|
||||||
|
:quartiers_prioritaires,
|
||||||
|
:cadastre
|
||||||
|
|
||||||
|
|
||||||
|
end
|
|
@ -1,11 +1,16 @@
|
||||||
class ProcedureSerializer < ActiveModel::Serializer
|
class ProcedureSerializer < ActiveModel::Serializer
|
||||||
|
attribute :libelle, key: :label
|
||||||
|
attribute :lien_demarche, key: :link
|
||||||
|
|
||||||
attributes :id,
|
attributes :id,
|
||||||
:libelle,
|
|
||||||
:description,
|
:description,
|
||||||
:organisation,
|
:organisation,
|
||||||
:direction,
|
:direction,
|
||||||
:lien_demarche,
|
:archived,
|
||||||
:archived
|
:geographic_information
|
||||||
|
|
||||||
|
|
||||||
|
has_one :geographic_information, serializer: ModuleApiCartoSerializer
|
||||||
has_many :types_de_champ, serializer: TypeDeChampSerializer
|
has_many :types_de_champ, serializer: TypeDeChampSerializer
|
||||||
has_many :types_de_piece_justificative, serializer: TypeDePieceJustificativeSerializer
|
has_many :types_de_piece_justificative, serializer: TypeDePieceJustificativeSerializer
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,16 +18,17 @@ describe API::V1::ProceduresController do
|
||||||
subject { get :show, id: procedure, token: admin.api_token }
|
subject { get :show, id: procedure, token: admin.api_token }
|
||||||
it { expect(subject.status).to eq(200) }
|
it { expect(subject.status).to eq(200) }
|
||||||
describe 'body' do
|
describe 'body' do
|
||||||
let(:procedure) { create(:procedure, :with_type_de_champ, :with_two_type_de_piece_justificative, administrateur: admin) }
|
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 }
|
let(:response) { get :show, id: procedure.id, token: admin.api_token }
|
||||||
subject { JSON.parse(response.body, symbolize_names: true)[:procedure] }
|
subject { JSON.parse(response.body, symbolize_names: true)[:procedure] }
|
||||||
|
|
||||||
it { expect(subject[:id]).to eq(procedure.id) }
|
it { expect(subject[:id]).to eq(procedure.id) }
|
||||||
it { expect(subject[:libelle]).to eq(procedure.libelle) }
|
it { expect(subject[:label]).to eq(procedure.libelle) }
|
||||||
it { expect(subject[:description]).to eq(procedure.description) }
|
it { expect(subject[:description]).to eq(procedure.description) }
|
||||||
it { expect(subject[:organisation]).to eq(procedure.organisation) }
|
it { expect(subject[:organisation]).to eq(procedure.organisation) }
|
||||||
it { expect(subject[:direction]).to eq(procedure.direction) }
|
it { expect(subject[:direction]).to eq(procedure.direction) }
|
||||||
it { expect(subject[:lien_demarche]).to eq(procedure.lien_demarche) }
|
it { expect(subject[:link]).to eq(procedure.lien_demarche) }
|
||||||
it { expect(subject[:archived]).to eq(procedure.archived) }
|
it { expect(subject[:archived]).to eq(procedure.archived) }
|
||||||
it { is_expected.to have_key(:types_de_champ) }
|
it { is_expected.to have_key(:types_de_champ) }
|
||||||
it { expect(subject[:types_de_champ]).to be_an(Array) }
|
it { expect(subject[:types_de_champ]).to be_an(Array) }
|
||||||
|
@ -50,6 +51,13 @@ describe API::V1::ProceduresController do
|
||||||
it { expect(subject[:libelle]).to eq(pj.libelle) }
|
it { expect(subject[:libelle]).to eq(pj.libelle) }
|
||||||
it { expect(subject[:description]).to eq(pj.description) }
|
it { expect(subject[:description]).to eq(pj.description) }
|
||||||
end
|
end
|
||||||
|
it { is_expected.to have_key(:geographic_information) }
|
||||||
|
describe 'geographic_information' do
|
||||||
|
subject { super()[:geographic_information] }
|
||||||
|
it { expect(subject[:use_api_carto]).to be_truthy }
|
||||||
|
it { expect(subject[:quartiers_prioritaires]).to be_truthy }
|
||||||
|
it { expect(subject[:cadastre]).to be_truthy }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue