Complete API Dossier
This commit is contained in:
parent
a316165792
commit
16c72e7478
7 changed files with 115 additions and 35 deletions
6
app/serializers/cerfa_serializer.rb
Normal file
6
app/serializers/cerfa_serializer.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
class CerfaSerializer < ActiveModel::Serializer
|
||||
|
||||
attributes :content_url => :url
|
||||
|
||||
has_one :type_de_champ
|
||||
end
|
5
app/serializers/champ_serializer.rb
Normal file
5
app/serializers/champ_serializer.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class ChampSerializer < ActiveModel::Serializer
|
||||
attributes :value
|
||||
|
||||
has_one :type_de_champ
|
||||
end
|
|
@ -4,8 +4,12 @@ class DossierSerializer < ActiveModel::Serializer
|
|||
:description,
|
||||
:created_at,
|
||||
:updated_at,
|
||||
:archived
|
||||
:archived,
|
||||
:mandataire_social
|
||||
|
||||
has_one :entreprise
|
||||
has_one :etablissement
|
||||
has_one :cerfa
|
||||
has_many :champs
|
||||
has_many :pieces_justificatives
|
||||
end
|
5
app/serializers/piece_justificative_serializer.rb
Normal file
5
app/serializers/piece_justificative_serializer.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class PieceJustificativeSerializer < ActiveModel::Serializer
|
||||
attributes :content_url => :url
|
||||
|
||||
has_one :type_de_piece_justificative
|
||||
end
|
|
@ -1,7 +1,7 @@
|
|||
class TypeDeChampSerializer < ActiveModel::Serializer
|
||||
attributes :id,
|
||||
:libelle,
|
||||
:type_champ,
|
||||
{:type_champ => :type},
|
||||
:order_place,
|
||||
:description
|
||||
end
|
|
@ -2,7 +2,7 @@ require 'spec_helper'
|
|||
|
||||
describe API::V1::DossiersController do
|
||||
let(:admin) { create(:administrateur) }
|
||||
let(:procedure) { create(:procedure, administrateur: admin) }
|
||||
let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, administrateur: admin) }
|
||||
let(:wrong_procedure) { create(:procedure) }
|
||||
|
||||
it { expect(described_class).to be < APIController }
|
||||
|
@ -114,7 +114,7 @@ describe API::V1::DossiersController do
|
|||
let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, procedure: procedure) } }
|
||||
let(:dossier_id) { dossier.id }
|
||||
let(:body) { JSON.parse(response.body, symbolize_names: true) }
|
||||
let(:field_list) { [:id, :nom_projet, :created_at, :updated_at, :description, :archived, :entreprise, :etablissement] }
|
||||
let(:field_list) { [:id, :nom_projet, :created_at, :updated_at, :description, :archived, :mandataire_social, :entreprise, :etablissement] }
|
||||
subject { body[:dossier] }
|
||||
|
||||
it { expect(response.code).to eq('200') }
|
||||
|
@ -124,28 +124,30 @@ describe API::V1::DossiersController do
|
|||
it { expect(subject[:updated_at]).to eq('2008-09-01T08:05:00.000Z') }
|
||||
it { expect(subject[:description]).to eq(dossier.description) }
|
||||
it { expect(subject[:archived]).to eq(dossier.archived) }
|
||||
it { expect(subject[:mandataire_social]).to eq(dossier.mandataire_social) }
|
||||
|
||||
it { expect(subject.keys).to match_array(field_list) }
|
||||
|
||||
describe 'entreprise' do
|
||||
let(:field_list) { [
|
||||
:siren,
|
||||
:capital_social,
|
||||
:numero_tva_intracommunautaire,
|
||||
:forme_juridique,
|
||||
:forme_juridique_code,
|
||||
:nom_commercial,
|
||||
:raison_sociale,
|
||||
:siret_siege_social,
|
||||
:code_effectif_entreprise,
|
||||
:date_creation,
|
||||
:nom,
|
||||
:prenom] }
|
||||
subject { super()[:entreprise]}
|
||||
:siren,
|
||||
:capital_social,
|
||||
:numero_tva_intracommunautaire,
|
||||
:forme_juridique,
|
||||
:forme_juridique_code,
|
||||
:nom_commercial,
|
||||
:raison_sociale,
|
||||
:siret_siege_social,
|
||||
:code_effectif_entreprise,
|
||||
:date_creation,
|
||||
:nom,
|
||||
:prenom] }
|
||||
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') }
|
||||
|
@ -155,22 +157,80 @@ describe API::V1::DossiersController do
|
|||
it { expect(subject.keys).to match_array(field_list) }
|
||||
end
|
||||
|
||||
describe 'pieces_justificatives' do
|
||||
let(:field_list) { [
|
||||
:url] }
|
||||
subject { super()[:pieces_justificatives] }
|
||||
|
||||
it { expect(subject.length).to eq 2 }
|
||||
|
||||
describe 'first piece justificative' do
|
||||
subject { super().first }
|
||||
|
||||
it { expect(subject.keys.include?(:url)).to be_truthy }
|
||||
it { expect(subject.keys.include?(:type_de_piece_justificative)).to be_truthy }
|
||||
|
||||
describe 'type de piece justificative' do
|
||||
let(:field_list) { [
|
||||
:id,
|
||||
:libelle,
|
||||
:description] }
|
||||
subject { super()[:type_de_piece_justificative] }
|
||||
|
||||
it { expect(subject.keys.include?(:id)).to be_truthy }
|
||||
it { expect(subject[:libelle]).to eq('RIB') }
|
||||
it { expect(subject[:description]).to eq('Releve identité bancaire') }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'champs' do
|
||||
let(:field_list) { [
|
||||
:url] }
|
||||
subject { super()[:champs] }
|
||||
|
||||
it { expect(subject.length).to eq 1 }
|
||||
|
||||
describe 'first champs' do
|
||||
subject { super().first }
|
||||
|
||||
it { expect(subject.keys.include?(:value)).to be_truthy }
|
||||
it { expect(subject.keys.include?(:type_de_champ)).to be_truthy }
|
||||
|
||||
describe 'type de champ' do
|
||||
let(:field_list) { [
|
||||
:id,
|
||||
:libelle,
|
||||
:description,
|
||||
:order_place,
|
||||
:type] }
|
||||
subject { super()[:type_de_champ] }
|
||||
|
||||
it { expect(subject.keys.include?(:id)).to be_truthy }
|
||||
it { expect(subject[:libelle]).to eq('Description') }
|
||||
it { expect(subject[:description]).to eq('description de votre projet') }
|
||||
it { expect(subject.keys.include?(:order_place)).to be_truthy }
|
||||
it { expect(subject[:type]).to eq('textarea') }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'etablissement' do
|
||||
let(:field_list) { [
|
||||
:siret,
|
||||
:siege_social,
|
||||
:naf,
|
||||
:libelle_naf,
|
||||
:adresse,
|
||||
:numero_voie,
|
||||
:type_voie,
|
||||
:nom_voie,
|
||||
:complement_adresse,
|
||||
:code_postal,
|
||||
:localite,
|
||||
:code_insee_localite
|
||||
:siret,
|
||||
:siege_social,
|
||||
:naf,
|
||||
:libelle_naf,
|
||||
:adresse,
|
||||
:numero_voie,
|
||||
:type_voie,
|
||||
:nom_voie,
|
||||
:complement_adresse,
|
||||
:code_postal,
|
||||
: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) }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
FactoryGirl.define do
|
||||
factory :type_de_champ do
|
||||
libelle 'Libellé'
|
||||
libelle 'Description'
|
||||
description 'description de votre projet'
|
||||
type_champ 'textarea'
|
||||
order_place 1
|
||||
|
|
Loading…
Add table
Reference in a new issue