diff --git a/app/lib/api_entreprise/exercices_adapter.rb b/app/lib/api_entreprise/exercices_adapter.rb index 1bdb961f3..b7d7c1d29 100644 --- a/app/lib/api_entreprise/exercices_adapter.rb +++ b/app/lib/api_entreprise/exercices_adapter.rb @@ -4,7 +4,7 @@ class ApiEntreprise::ExercicesAdapter @procedure_id = procedure_id end - def to_params + def to_array data_source[:exercices].map do |exercice| exercice.slice(*attr_to_fetch) end diff --git a/app/services/siret_service.rb b/app/services/siret_service.rb index 797420935..3c19a5f34 100644 --- a/app/services/siret_service.rb +++ b/app/services/siret_service.rb @@ -10,7 +10,7 @@ class SIRETService params = etablissement.to_params .merge(entreprise.to_params.map { |k,v| ["entreprise_#{k}", v] }.to_h) .merge(association.to_params&.map { |k,v| ["association_#{k}", v] }.to_h) - .merge(exercices_attributes: exercices.to_params) + .merge(exercices_attributes: exercices.to_array) # This is to fill legacy models and relationships if dossier.present? diff --git a/spec/lib/api_entreprise/exercices_adapter_spec.rb b/spec/lib/api_entreprise/exercices_adapter_spec.rb index 9e9d29bb8..591a8e395 100644 --- a/spec/lib/api_entreprise/exercices_adapter_spec.rb +++ b/spec/lib/api_entreprise/exercices_adapter_spec.rb @@ -3,14 +3,14 @@ require 'spec_helper' describe ApiEntreprise::ExercicesAdapter do let(:siret) { '41816609600051' } let(:procedure_id) { 11 } - subject { described_class.new(siret, procedure_id).to_params } + subject { described_class.new(siret, procedure_id).to_array } before do stub_request(:get, /https:\/\/staging.entreprise.api.gouv.fr\/v2\/exercices\/.*token=/) .to_return(body: File.read('spec/support/files/exercices.json', status: 200)) end - it '#to_params class est une Hash ?' do + it '#to_array class est un Array ?' do expect(subject).to be_an_instance_of(Array) end