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

27 lines
1 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
2020-08-05 18:40:47 +02:00
RSpec.describe APIEntreprise::BilansBdfJob, 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(:procedure_id) { procedure.id }
let(:body) { File.read('spec/fixtures/files/api_entreprise/bilans_entreprise_bdf.json') }
let(:status) { 200 }
2023-05-28 13:10:18 +02:00
let(:bilans_bdf) { JSON.parse(body)["data"] }
2020-05-14 10:56:26 +02:00
before do
2023-05-28 13:10:18 +02:00
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v3\/banque_de_france\/unites_legales\/#{siren}\/bilans/)
2020-05-14 10:56:26 +02:00
.to_return(body: body, status: status)
2020-08-05 18:40:47 +02:00
allow_any_instance_of(APIEntrepriseToken).to receive(:roles).and_return(["bilans_entreprise_bdf"])
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::BilansBdfJob.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_bilans_bdf).to eq(bilans_bdf)
end
end