Merge pull request #2766 from betagouv/2759-followup

#2759 follow-up
This commit is contained in:
gregoirenovel 2018-10-05 00:01:27 +02:00 committed by GitHub
commit 0d7197392a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 8 deletions

View file

@ -10,7 +10,7 @@ class ApiEntreprise::ExercicesAdapter < ApiEntreprise::Adapter
exercice.slice(*attr_to_fetch)
end
if exercices_array == exercices_array.select { |params| valid_params?(params) }
if exercices_array.all? { |params| valid_params?(params) }
{ exercices_attributes: exercices_array }
else
{}

View file

@ -6,17 +6,20 @@ class ApiEntreprise::RNAAdapter < ApiEntreprise::Adapter
end
def process_params
# Responses with a 206 codes are sometimes not useable,
# as the RNA calls often return a 206 with an error message,
# not a partial response
# Sometimes the associations endpoints responses with a 206,
# and these response are often useable as the they only
# contain an error message.
# Therefore here we make sure that our response seems valid
# by checking that there is an association attribute.
if !data_source.key?(:association)
{}
else
association_id = data_source[:association][:id]
params = data_source[:association].slice(*attr_to_fetch)
if params[:id].present? && valid_params?(params)
params[:rna] = params[:id]
params.except(:id).transform_keys { |k| :"association_#{k}" }
if association_id.present? && valid_params?(params)
params[:rna] = association_id
params.transform_keys { |k| :"association_#{k}" }
else
{}
end
@ -25,7 +28,6 @@ class ApiEntreprise::RNAAdapter < ApiEntreprise::Adapter
def attr_to_fetch
[
:id,
:titre,
:objet,
:date_creation,