fix spec with not expired token
and use of `ApiEntrepriseToken#roles`
This commit is contained in:
parent
dbf04dd0d8
commit
dba77ec0b8
11 changed files with 19 additions and 5 deletions
|
@ -78,7 +78,8 @@ feature 'Creating a new dossier:' do
|
|||
.to_return(status: 404, body: '')
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/effectifs_annuels_acoss_covid\/#{siren}?.*token=/)
|
||||
.to_return(status: 404, body: '')
|
||||
allow_any_instance_of(Procedure).to receive(:api_entreprise_roles).and_return([])
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:roles).and_return([])
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
||||
end
|
||||
before { Timecop.freeze(Time.zone.local(2020, 3, 14)) }
|
||||
after { Timecop.return }
|
||||
|
|
|
@ -8,7 +8,8 @@ describe ApiEntreprise::AttestationFiscaleAdapter do
|
|||
before do
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/attestations_fiscales_dgfip\/#{siren}?.*token=/)
|
||||
.to_return(body: body, status: status)
|
||||
allow_any_instance_of(Procedure).to receive(:api_entreprise_roles).and_return(["attestations_fiscales"])
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:roles).and_return(["attestations_fiscales"])
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
||||
end
|
||||
|
||||
context "when the SIREN is valid" do
|
||||
|
|
|
@ -7,7 +7,8 @@ describe ApiEntreprise::AttestationSocialeAdapter do
|
|||
before do
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/attestations_sociales_acoss\/#{siren}?.*token=/)
|
||||
.to_return(body: body, status: status)
|
||||
allow_any_instance_of(Procedure).to receive(:api_entreprise_roles).and_return(["attestations_sociales"])
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:roles).and_return(["attestations_sociales"])
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
||||
end
|
||||
|
||||
context "when the SIREN is valid" do
|
||||
|
|
|
@ -8,7 +8,8 @@ describe ApiEntreprise::BilansBdfAdapter do
|
|||
before do
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/bilans_entreprises_bdf\/#{siren}?.*token=/)
|
||||
.to_return(body: body, status: status)
|
||||
allow_any_instance_of(Procedure).to receive(:api_entreprise_roles).and_return(["bilans_entreprise_bdf"])
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:roles).and_return(["bilans_entreprise_bdf"])
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
||||
end
|
||||
|
||||
context "when the SIREN is valid" do
|
||||
|
|
|
@ -10,6 +10,7 @@ describe ApiEntreprise::EffectifsAdapter do
|
|||
before do
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/effectifs_mensuels_acoss_covid\/#{annee}\/#{mois}\/entreprise\/#{siren}?.*token=/)
|
||||
.to_return(body: body, status: status)
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
||||
end
|
||||
|
||||
context "when the SIREN is valid" do
|
||||
|
|
|
@ -8,6 +8,7 @@ describe ApiEntreprise::EffectifsAnnuelsAdapter do
|
|||
before do
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/effectifs_annuels_acoss_covid\/#{siren}?.*token=/)
|
||||
.to_return(body: body, status: status)
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
||||
end
|
||||
|
||||
context "when the SIREN is valid" do
|
||||
|
|
|
@ -8,6 +8,7 @@ describe ApiEntreprise::EntrepriseAdapter do
|
|||
before do
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/entreprises\/#{siren}?.*token=/)
|
||||
.to_return(body: body, status: status)
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
||||
end
|
||||
|
||||
context "when the SIRET is valid" do
|
||||
|
|
|
@ -2,6 +2,10 @@ describe ApiEntreprise::EtablissementAdapter do
|
|||
let(:procedure) { create(:procedure) }
|
||||
let(:procedure_id) { procedure.id }
|
||||
|
||||
before do
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
||||
end
|
||||
|
||||
context 'SIRET valide avec infos diffusables' do
|
||||
let(:siret) { '41816609600051' }
|
||||
subject { described_class.new(siret, procedure_id).to_params }
|
||||
|
|
|
@ -6,6 +6,7 @@ describe ApiEntreprise::ExercicesAdapter do
|
|||
before do
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/exercices\/.*token=/)
|
||||
.to_return(body: File.read('spec/fixtures/files/api_entreprise/exercices.json', status: 200))
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
||||
end
|
||||
|
||||
it { is_expected.to be_an_instance_of(Hash) }
|
||||
|
|
|
@ -11,6 +11,7 @@ describe ApiEntreprise::RNAAdapter do
|
|||
before do
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/associations\/.*token=/)
|
||||
.to_return(body: body, status: status)
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
||||
end
|
||||
|
||||
context 'when siret is not valid' do
|
||||
|
|
|
@ -68,8 +68,9 @@ describe ApiEntrepriseService do
|
|||
let(:result) { ApiEntrepriseService.get_etablissement_params_for_siret(siret, procedure.id) }
|
||||
|
||||
before do
|
||||
allow_any_instance_of(Procedure).to receive(:api_entreprise_roles)
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:roles)
|
||||
.and_return(["attestations_sociales", "attestations_fiscales", "bilans_entreprise_bdf"])
|
||||
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
|
||||
end
|
||||
|
||||
context 'when service is up' do
|
||||
|
|
Loading…
Reference in a new issue