Skip to content

Commit

Permalink
Création d'un fichier répertoriant les collèges autorisés dans APLyPro
Browse files Browse the repository at this point in the history
  • Loading branch information
tnicolas1 committed Oct 18, 2024
1 parent 4cb328e commit a6a8c2d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/models/concerns/identity_mappers/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
8 changes: 8 additions & 0 deletions config/initializers/authorised_establishments.rb
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions data/authorised-establishments.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
uai
9760371Z
9760379H
9760274U
9760167C
9760369X
10 changes: 10 additions & 0 deletions spec/models/concerns/identity_mappers/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a6a8c2d

Please sign in to comment.