Merge pull request #4164 from tchak/fix-api-attestation
Fix attestation url for dossiers with no attestation
This commit is contained in:
commit
edac358334
2 changed files with 17 additions and 2 deletions
|
@ -58,7 +58,7 @@ class DossierSerializer < ActiveModel::Serializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def attestation
|
def attestation
|
||||||
object.attestation.pdf_url
|
object.attestation&.pdf_url
|
||||||
end
|
end
|
||||||
|
|
||||||
def justificatif_motivation
|
def justificatif_motivation
|
||||||
|
|
|
@ -151,10 +151,25 @@ describe API::V1::DossiersController do
|
||||||
it { expect(subject.code).to eq('404') }
|
it { expect(subject.code).to eq('404') }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when dossier (with attestation) exists and belongs to procedure' do
|
||||||
|
let(:procedure_id) { procedure.id }
|
||||||
|
let(:dossier_id) { dossier.id }
|
||||||
|
let!(:dossier) { create(:dossier, :with_entreprise, :with_attestation, :accepte, procedure: procedure, motivation: "Motivation") }
|
||||||
|
let(:body) { JSON.parse(retour.body, symbolize_names: true) }
|
||||||
|
subject { body[:dossier] }
|
||||||
|
|
||||||
|
it {
|
||||||
|
expect(retour.code).to eq('200')
|
||||||
|
expect(subject[:id]).to eq(dossier.id)
|
||||||
|
expect(subject[:state]).to eq('closed')
|
||||||
|
expect(subject[:attestation]).to_not be_nil
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
context 'when dossier exists and belongs to procedure' do
|
context 'when dossier exists and belongs to procedure' do
|
||||||
let(:procedure_id) { procedure.id }
|
let(:procedure_id) { procedure.id }
|
||||||
let(:date_creation) { Time.zone.local(2008, 9, 1, 10, 5, 0) }
|
let(:date_creation) { Time.zone.local(2008, 9, 1, 10, 5, 0) }
|
||||||
let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, :with_attestation, :accepte, procedure: procedure, motivation: "Motivation") } }
|
let!(:dossier) { Timecop.freeze(date_creation) { create(:dossier, :with_entreprise, :accepte, procedure: procedure, motivation: "Motivation") } }
|
||||||
let(:dossier_id) { dossier.id }
|
let(:dossier_id) { dossier.id }
|
||||||
let(:body) { JSON.parse(retour.body, symbolize_names: true) }
|
let(:body) { JSON.parse(retour.body, symbolize_names: true) }
|
||||||
let(:field_list) { [:id, :created_at, :updated_at, :archived, :individual, :entreprise, :etablissement, :cerfa, :types_de_piece_justificative, :pieces_justificatives, :champs, :champs_private, :commentaires, :state, :simplified_state, :initiated_at, :processed_at, :received_at, :motivation, :email, :instructeurs, :attestation, :avis] }
|
let(:field_list) { [:id, :created_at, :updated_at, :archived, :individual, :entreprise, :etablissement, :cerfa, :types_de_piece_justificative, :pieces_justificatives, :champs, :champs_private, :commentaires, :state, :simplified_state, :initiated_at, :processed_at, :received_at, :motivation, :email, :instructeurs, :attestation, :avis] }
|
||||||
|
|
Loading…
Reference in a new issue