Merge pull request #8409 from colinux/fix-association-adapter
Fix RNA Association adapter sans date_publication
This commit is contained in:
commit
6915671f95
3 changed files with 26 additions and 13 deletions
|
@ -15,15 +15,23 @@ class APIEntreprise::RNAAdapter < APIEntreprise::Adapter
|
|||
|
||||
def process_params
|
||||
params = data_source[:association]
|
||||
params = params&.slice(*attr_to_fetch) if @depreciated
|
||||
params[:rna] = data_source.dig(:association, :id)
|
||||
if params[:rna].present? && valid_params?(params)
|
||||
params = params.transform_keys { |k| :"association_#{k}" }.deep_stringify_keys
|
||||
raise InvalidSchemaError.new(schemer.validate(params).to_a) unless schemer.valid?(params)
|
||||
|
||||
params
|
||||
else
|
||||
{}
|
||||
Sentry.with_scope do |scope|
|
||||
scope.set_tags(siret: @siret)
|
||||
scope.set_extras(source: params)
|
||||
|
||||
params = params&.slice(*attr_to_fetch) if @depreciated
|
||||
params[:rna] = data_source.dig(:association, :id)
|
||||
|
||||
if params[:rna].present? && valid_params?(params)
|
||||
params = params.transform_keys { |k| :"association_#{k}" }.deep_stringify_keys
|
||||
|
||||
raise InvalidSchemaError.new(schemer.validate(params).to_a) unless schemer.valid?(params)
|
||||
|
||||
params
|
||||
else
|
||||
{}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -29,8 +29,15 @@
|
|||
"format": "date"
|
||||
},
|
||||
"association_date_publication": {
|
||||
"type": "string",
|
||||
"format": "date"
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"format": "date"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"association_date_dissolution": {
|
||||
"anyOf": [
|
||||
|
@ -236,7 +243,6 @@
|
|||
"required": [
|
||||
"association_titre",
|
||||
"association_rna",
|
||||
"association_date_declaration",
|
||||
"association_date_publication"
|
||||
"association_date_declaration"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ describe APIEntreprise::RNAAdapter do
|
|||
expect(subject["association_titre"]).to eq('UN SUR QUATRE')
|
||||
expect(subject["association_objet"]).to eq("valoriser, transmettre et partager auprès des publics les plus larges possibles, les bienfaits de l'immigration, la richesse de la diversité et la curiosité de l'autre autrement")
|
||||
expect(subject["association_date_declaration"]).to eq('2014-01-24')
|
||||
expect(subject["association_date_publication"]).to eq('2014-02-08')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue