tech(rna_controller#show): corrige les specs et recupère uniquement les informations utilisé par l'app
This commit is contained in:
parent
ef82149a3b
commit
0d3deb01be
4 changed files with 18 additions and 62 deletions
|
@ -9,7 +9,7 @@ class APIEntreprise::RNAAdapter < APIEntreprise::Adapter
|
|||
end
|
||||
|
||||
def process_params
|
||||
data = data_source[:data]
|
||||
data, meta = data_source.values_at(:data, :meta)
|
||||
return {} if data.nil?
|
||||
|
||||
Sentry.with_scope do |scope|
|
||||
|
@ -21,7 +21,8 @@ class APIEntreprise::RNAAdapter < APIEntreprise::Adapter
|
|||
"association_titre" => data[:nom],
|
||||
"association_objet" => data[:activites][:objet],
|
||||
"association_date_creation" => data[:date_creation],
|
||||
"association_date_declaration" => data[:date_publication_journal_officiel],
|
||||
# see: https://mattermost.incubateur.net/betagouv/pl/r6txumw9cpyx58rt7iq5dte9qe
|
||||
"association_date_declaration" => meta[:date_derniere_mise_a_jour_rna],
|
||||
"association_date_publication" => data[:date_publication_journal_officiel]
|
||||
}
|
||||
end
|
||||
|
|
|
@ -25,7 +25,7 @@ describe Champs::RNAController, type: :controller do
|
|||
|
||||
before do
|
||||
sign_in user
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/associations\//)
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v4\/djepva\/api-association\/associations\/open_data\/#{rna}/)
|
||||
.to_return(body: body, status: status)
|
||||
allow_any_instance_of(APIEntrepriseToken).to receive(:expired?).and_return(false)
|
||||
end
|
||||
|
@ -103,43 +103,18 @@ describe Champs::RNAController, type: :controller do
|
|||
let(:rna) { 'W595001988' }
|
||||
let(:status) { 200 }
|
||||
let(:body) { File.read('spec/fixtures/files/api_entreprise/associations.json') }
|
||||
let(:expected_data) do
|
||||
{
|
||||
"association_id" => "W595001988",
|
||||
"association_titre" => "UN SUR QUATRE",
|
||||
"association_objet" => "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",
|
||||
"association_siret" => nil,
|
||||
"association_date_creation" => "2014-01-23",
|
||||
"association_date_declaration" => "2014-01-24",
|
||||
"association_date_publication" => "2014-02-08",
|
||||
"association_date_dissolution" => "0001-01-01",
|
||||
"association_adresse_siege" => {
|
||||
"complement" => "",
|
||||
"numero_voie" => "61",
|
||||
"type_voie" => "RUE",
|
||||
"libelle_voie" => "des Noyers",
|
||||
"distribution" => "_",
|
||||
"code_insee" => "93063",
|
||||
"code_postal" => "93230",
|
||||
"commune" => "Romainville"
|
||||
},
|
||||
"association_code_civilite_dirigeant" => "PM",
|
||||
"association_civilite_dirigeant" => "Monsieur le Président",
|
||||
"association_code_etat" => "A",
|
||||
"association_etat" => "Active",
|
||||
"association_code_groupement" => "S",
|
||||
"association_groupement" => "simple",
|
||||
"association_mise_a_jour" => 1392295833,
|
||||
"association_rna" => "W595001988"
|
||||
}
|
||||
end
|
||||
|
||||
subject! { get :show, params: params, format: :turbo_stream }
|
||||
|
||||
it 'populates the data and RNA on the model' do
|
||||
champ.reload
|
||||
expect(champ.value).to eq(rna)
|
||||
expect(champ.data).to eq(expected_data)
|
||||
expect(champ.data["association_titre"]).to eq("LA PRÉVENTION ROUTIERE")
|
||||
expect(champ.data["association_objet"]).to eq("L'association a pour objet de promouvoir la pratique du sport de haut niveau et de contribuer à la formation des jeunes sportifs.")
|
||||
expect(champ.data["association_date_creation"]).to eq("2015-01-01")
|
||||
expect(champ.data["association_date_declaration"]).to eq("2019-01-01")
|
||||
expect(champ.data["association_date_publication"]).to eq("2018-01-01")
|
||||
expect(champ.data["association_rna"]).to eq("W751080001")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -29,7 +29,7 @@ describe APIEntreprise::RNAAdapter do
|
|||
expect(subject["association_rna"]).to eq("W751080001")
|
||||
expect(subject["association_titre"]).to eq("LA PRÉVENTION ROUTIERE")
|
||||
expect(subject["association_objet"]).to eq("L'association a pour objet de promouvoir la pratique du sport de haut niveau et de contribuer à la formation des jeunes sportifs.")
|
||||
expect(subject["association_date_declaration"]).to eq("2018-01-01")
|
||||
expect(subject["association_date_declaration"]).to eq("2019-01-01")
|
||||
expect(subject["association_date_publication"]).to eq("2018-01-01")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ RSpec.describe RNAChampAssociationFetchableConcern do
|
|||
let!(:champ) { create(:champ_rna, data: "not nil data", value: 'W173847273') }
|
||||
|
||||
before do
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/associations\//)
|
||||
stub_request(:get, /https:\/\/entreprise.api.gouv.fr\/v4\/djepva\/api-association\/associations\/open_data\/#{rna}/)
|
||||
.to_return(body: body, status: status)
|
||||
allow_any_instance_of(APIEntrepriseToken).to receive(:expired?).and_return(false)
|
||||
end
|
||||
|
@ -63,32 +63,12 @@ RSpec.describe RNAChampAssociationFetchableConcern do
|
|||
let(:body) { File.read('spec/fixtures/files/api_entreprise/associations.json') }
|
||||
|
||||
it_behaves_like "an association fetcher", true, nil, 'W595001988', {
|
||||
"association_id" => "W595001988",
|
||||
"association_titre" => "UN SUR QUATRE",
|
||||
"association_objet" => "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",
|
||||
"association_siret" => nil,
|
||||
"association_date_creation" => "2014-01-23",
|
||||
"association_date_declaration" => "2014-01-24",
|
||||
"association_date_publication" => "2014-02-08",
|
||||
"association_date_dissolution" => "0001-01-01",
|
||||
"association_adresse_siege" => {
|
||||
"complement" => "",
|
||||
"numero_voie" => "61",
|
||||
"type_voie" => "RUE",
|
||||
"libelle_voie" => "des Noyers",
|
||||
"distribution" => "_",
|
||||
"code_insee" => "93063",
|
||||
"code_postal" => "93230",
|
||||
"commune" => "Romainville"
|
||||
},
|
||||
"association_code_civilite_dirigeant" => "PM",
|
||||
"association_civilite_dirigeant" => "Monsieur le Président",
|
||||
"association_code_etat" => "A",
|
||||
"association_etat" => "Active",
|
||||
"association_code_groupement" => "S",
|
||||
"association_groupement" => "simple",
|
||||
"association_mise_a_jour" => 1392295833,
|
||||
"association_rna" => "W595001988"
|
||||
"association_titre" => "LA PRÉVENTION ROUTIERE",
|
||||
"association_objet" => "L'association a pour objet de promouvoir la pratique du sport de haut niveau et de contribuer à la formation des jeunes sportifs.",
|
||||
"association_date_creation" => "2015-01-01",
|
||||
"association_date_declaration" => "2019-01-01",
|
||||
"association_date_publication" => "2018-01-01",
|
||||
"association_rna" => "W751080001"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue