store attestation fiscale and display

This commit is contained in:
Christophe Robillard 2020-04-29 18:57:30 +02:00
parent 38c68b16e3
commit 3ddb5a4cb4
6 changed files with 45 additions and 6 deletions

View file

@ -224,6 +224,9 @@ describe Users::DossiersController, type: :controller do
let(:api_entreprise_attestation_sociale_status) { 200 }
let(:api_entreprise_attestation_sociale_body) { File.read('spec/fixtures/files/api_entreprise/attestation_sociale.json') }
let(:api_entreprise_attestation_fiscale_status) { 200 }
let(:api_entreprise_attestation_fiscale_body) { File.read('spec/fixtures/files/api_entreprise/attestation_fiscale.json') }
def stub_api_entreprise_requests
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/etablissements\/#{siret}?.*token=/)
.to_return(status: api_etablissement_status, body: api_etablissement_body)
@ -241,12 +244,16 @@ describe Users::DossiersController, type: :controller do
.to_return(body: api_entreprise_attestation_sociale_body, status: api_entreprise_attestation_sociale_status)
stub_request(:get, "https://storage.entreprise.api.gouv.fr/siade/1569156881-f749d75e2bfd443316e2e02d59015f-attestation_vigilance_acoss.pdf")
.to_return(body: "body attestation", status: 200)
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/attestations_fiscales_dgfip\/#{siren}?.*token=/)
.to_return(body: api_entreprise_attestation_fiscale_body, status: api_entreprise_attestation_fiscale_status)
stub_request(:get, "https://storage.entreprise.api.gouv.fr/siade/1569156756-f6b7779f99fa95cd60dc03c04fcb-attestation_fiscale_dgfip.pdf")
.to_return(body: "body attestation", status: 200)
end
before do
sign_in(user)
stub_api_entreprise_requests
allow_any_instance_of(Procedure).to receive(:api_entreprise_roles).and_return(["entreprises", "attestations_sociales"])
allow_any_instance_of(Procedure).to receive(:api_entreprise_roles).and_return(["attestations_fiscales", "attestations_sociales"])
end
before { Timecop.freeze(Time.zone.local(2020, 3, 14)) }
after { Timecop.return }
@ -343,6 +350,7 @@ describe Users::DossiersController, type: :controller do
expect(dossier.etablissement.entreprise_effectif_mensuel).to be_present
expect(dossier.etablissement.entreprise_effectif_annuel).to be_present
expect(dossier.etablissement.entreprise_attestation_sociale).to be_attached
expect(dossier.etablissement.entreprise_attestation_fiscale).to be_attached
end
end
end