get most fresh info for effectifs mensuels
This commit is contained in:
parent
81f78c62b4
commit
e5d0d7dda2
3 changed files with 20 additions and 10 deletions
|
@ -1,8 +1,7 @@
|
|||
class APIEntreprise::EffectifsJob < APIEntreprise::Job
|
||||
def perform(etablissement_id, procedure_id)
|
||||
find_etablissement(etablissement_id)
|
||||
# may 2020 is at the moment the most actual info for effectifs endpoint
|
||||
etablissement_params = APIEntreprise::EffectifsAdapter.new(etablissement.siret, procedure_id, "2020", "05").to_params
|
||||
etablissement = Etablissement.find(etablissement_id)
|
||||
etablissement_params = APIEntreprise::EffectifsAdapter.new(etablissement.siret, procedure_id, *get_current_valid_month_for_effectif).to_params
|
||||
etablissement.update!(etablissement_params)
|
||||
end
|
||||
|
||||
|
|
|
@ -1,6 +1,17 @@
|
|||
{
|
||||
"siren": "418166096",
|
||||
"annee": "2020",
|
||||
"mois": "02",
|
||||
"effectifs_mensuels": 100.5
|
||||
"data": {
|
||||
"siret": "41816609600069",
|
||||
"effectifs_mensuels": [
|
||||
{
|
||||
"regime": "regime_general",
|
||||
"value": 12.34,
|
||||
"nature": "effectif_moyen_mensuel",
|
||||
"annee": "2020",
|
||||
"mois": "02",
|
||||
"date_derniere_mise_a_jour": "2018-01-01"
|
||||
}
|
||||
]
|
||||
},
|
||||
"links": {},
|
||||
"meta": {}
|
||||
}
|
||||
|
|
|
@ -6,12 +6,12 @@ RSpec.describe APIEntreprise::EffectifsJob, type: :job do
|
|||
let(:procedure_id) { procedure.id }
|
||||
let(:now) { Time.zone.local(2020, 3, 12) }
|
||||
let(:annee) { "2020" }
|
||||
let(:mois) { "05" }
|
||||
let(:mois) { "02" }
|
||||
let(:body) { File.read('spec/fixtures/files/api_entreprise/effectifs.json') }
|
||||
let(:status) { 200 }
|
||||
|
||||
before do
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/effectifs_mensuels_acoss_covid\/#{annee}\/#{mois}\/entreprise\/#{siren}/)
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v3\/gip_mds\/etablissements\/#{siret}\/effectifs_mensuels\/#{mois}\/annee\/#{annee}/)
|
||||
.to_return(body: body, status: status)
|
||||
allow_any_instance_of(APIEntrepriseToken).to receive(:expired?).and_return(false)
|
||||
end
|
||||
|
@ -23,6 +23,6 @@ RSpec.describe APIEntreprise::EffectifsJob, type: :job do
|
|||
|
||||
it 'updates etablissement' do
|
||||
subject
|
||||
expect(Etablissement.find(etablissement.id).entreprise_effectif_mensuel).to eq(100.5)
|
||||
expect(Etablissement.find(etablissement.id).entreprise_effectif_mensuel).to eq(12.34)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue