From a6a8c2dfd521ca93df06ac5875b1361e7575a98a Mon Sep 17 00:00:00 2001 From: tnicolas1 Date: Fri, 18 Oct 2024 09:41:47 +0200 Subject: [PATCH] =?UTF-8?q?Cr=C3=A9ation=20d'un=20fichier=20r=C3=A9pertori?= =?UTF-8?q?ant=20les=20coll=C3=A8ges=20autoris=C3=A9s=20dans=20APLyPro?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/concerns/identity_mappers/base.rb | 3 ++- config/initializers/authorised_establishments.rb | 8 ++++++++ data/authorised-establishments.csv | 6 ++++++ spec/models/concerns/identity_mappers/base_spec.rb | 10 ++++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 config/initializers/authorised_establishments.rb create mode 100644 data/authorised-establishments.csv diff --git a/app/models/concerns/identity_mappers/base.rb b/app/models/concerns/identity_mappers/base.rb index aace42461..95c06a6f4 100644 --- a/app/models/concerns/identity_mappers/base.rb +++ b/app/models/concerns/identity_mappers/base.rb @@ -43,7 +43,8 @@ def no_value?(line) end def relevant?(attrs) - Establishment.accepted_type?(attrs[:tty_code]) && !Exclusion.establishment_excluded?(attrs[:uai]) + (Establishment.accepted_type?(attrs[:tty_code]) && !Exclusion.establishment_excluded?(attrs[:uai])) || + Aplypro::AUTHORISED_ESTABLISHMENTS.include?([attrs[:uai]]) end def no_responsibilities? diff --git a/config/initializers/authorised_establishments.rb b/config/initializers/authorised_establishments.rb new file mode 100644 index 000000000..52865c380 --- /dev/null +++ b/config/initializers/authorised_establishments.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +require "csv" + +module Aplypro + AUTHORISED_ESTABLISHMENTS = CSV.read(Rails.root.join("data/authorised-establishments.csv"), + headers: true, return_headers: false).to_a +end diff --git a/data/authorised-establishments.csv b/data/authorised-establishments.csv new file mode 100644 index 000000000..a2c1494d7 --- /dev/null +++ b/data/authorised-establishments.csv @@ -0,0 +1,6 @@ +uai +9760371Z +9760379H +9760274U +9760167C +9760369X \ No newline at end of file diff --git a/spec/models/concerns/identity_mappers/base_spec.rb b/spec/models/concerns/identity_mappers/base_spec.rb index 58678071d..5250b7ba4 100644 --- a/spec/models/concerns/identity_mappers/base_spec.rb +++ b/spec/models/concerns/identity_mappers/base_spec.rb @@ -61,6 +61,16 @@ expect(result).to contain_exactly "Z" end end + + context "when some establishments are added in the perimeter" do + let(:fredurne) { build(:fredurne, uai: "9760167C", tty_code: "CLG") } + let(:fredurneresp) { build(:fredurneresp, uai: "1234", tty_code: "CLG") } + let(:freduresdel) { build(:freduresdel, uai: "C", tty_code: "CLG") } + + it "filters them in" do + expect(result).to contain_exactly "9760167C" + end + end end describe "#establishments_authorised_for" do