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

21 lines
751 B
Ruby
Raw Normal View History

2020-05-14 10:56:26 +02:00
RSpec.describe ApiEntreprise::ExercicesJob, type: :job do
let(:siret) { '41816609600051' }
let(:procedure) { create(:procedure) }
let(:etablissement) { create(:etablissement, siret: siret) }
let(:body) { File.read('spec/fixtures/files/api_entreprise/exercices.json') }
let(:status) { 200 }
before do
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/exercices\//)
2020-05-14 10:56:26 +02:00
.to_return(body: body, status: status)
allow_any_instance_of(ApiEntrepriseToken).to receive(:expired?).and_return(false)
end
subject { ApiEntreprise::ExercicesJob.new.perform(etablissement.id, procedure.id) }
it 'updates etablissement' do
subject
expect(Etablissement.find(etablissement.id).exercices[0].ca).to eq('21009417')
end
end