demarches-normaliennes/spec/jobs/api_entreprise/attestation_sociale_job_spec.rb

27 lines
1.2 KiB
Ruby
Raw Normal View History

include ActiveJob::TestHelper
2020-08-05 18:40:47 +02:00
RSpec.describe APIEntreprise::AttestationSocialeJob, type: :job do
2020-05-14 10:56:26 +02:00
let(:etablissement) { create(:etablissement, siret: siret) }
let(:siret) { '41816609600069' }
let(:siren) { '418166096' }
let(:procedure) { create(:procedure) }
let(:body) { File.read('spec/fixtures/files/api_entreprise/attestation_sociale.json') }
let(:status) { 200 }
before do
2023-05-22 14:56:40 +02:00
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v4\/urssaf\/unites_legales\/#{siren}\/attestation_vigilance/)
2020-05-14 10:56:26 +02:00
.to_return(body: body, status: status)
2023-05-22 14:56:40 +02:00
stub_request(:get, "https://storage.entreprise.api.gouv.fr/siade/1569139162-b99824d9c764aae19a862a0af-attestation_vigilance_acoss.pdf")
2020-05-14 10:56:26 +02:00
.to_return(body: "body attestation", status: 200)
2020-08-05 18:40:47 +02:00
allow_any_instance_of(APIEntrepriseToken).to receive(:roles).and_return(["attestations_sociales"])
allow_any_instance_of(APIEntrepriseToken).to receive(:expired?).and_return(false)
2020-05-14 10:56:26 +02:00
end
2020-08-05 18:40:47 +02:00
subject { APIEntreprise::AttestationSocialeJob.new.perform(etablissement.id, procedure.id) }
2020-05-14 10:56:26 +02:00
it 'updates etablissement' do
subject
expect(Etablissement.find(etablissement.id).entreprise_attestation_sociale).to be_attached
end
end