feat(file retrieval): create agent connect information

This commit is contained in:
simon lehericey 2023-12-12 14:23:42 +01:00
parent 4e023ebed0
commit 277ac1259a
7 changed files with 57 additions and 1 deletions

View file

@ -0,0 +1,3 @@
class AgentConnectInformation < ApplicationRecord
belongs_to :instructeur
end

View file

@ -2,6 +2,8 @@ class Instructeur < ApplicationRecord
include UserFindByConcern include UserFindByConcern
has_and_belongs_to_many :administrateurs has_and_belongs_to_many :administrateurs
has_one :agent_connect_information, dependent: :destroy
has_many :assign_to, dependent: :destroy has_many :assign_to, dependent: :destroy
has_many :groupe_instructeurs, -> { order(:label) }, through: :assign_to has_many :groupe_instructeurs, -> { order(:label) }, through: :assign_to
has_many :unordered_groupe_instructeurs, through: :assign_to, source: :groupe_instructeur has_many :unordered_groupe_instructeurs, through: :assign_to, source: :groupe_instructeur

View file

@ -0,0 +1,17 @@
class CreateAgentConnectInformations < ActiveRecord::Migration[7.0]
def change
create_table :agent_connect_informations do |t|
t.references :instructeur, null: false, foreign_key: true
t.string :given_name, null: false
t.string :usual_name, null: false
t.string :email, null: false
t.string :sub, null: false
t.string :siret
t.string :organizational_unit
t.string :belonging_population
t.string :phone
t.timestamps
end
end
end

View file

@ -91,6 +91,21 @@ ActiveRecord::Schema[7.0].define(version: 2024_02_27_163855) do
t.index ["procedure_id"], name: "index_administrateurs_procedures_on_procedure_id" t.index ["procedure_id"], name: "index_administrateurs_procedures_on_procedure_id"
end end
create_table "agent_connect_informations", force: :cascade do |t|
t.string "belonging_population"
t.datetime "created_at", null: false
t.string "email", null: false
t.string "given_name", null: false
t.bigint "instructeur_id", null: false
t.string "organizational_unit"
t.string "phone"
t.string "siret"
t.string "sub", null: false
t.datetime "updated_at", null: false
t.string "usual_name", null: false
t.index ["instructeur_id"], name: "index_agent_connect_informations_on_instructeur_id"
end
create_table "api_tokens", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| create_table "api_tokens", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.bigint "administrateur_id", null: false t.bigint "administrateur_id", null: false
t.bigint "allowed_procedure_ids", array: true t.bigint "allowed_procedure_ids", array: true
@ -1179,6 +1194,7 @@ ActiveRecord::Schema[7.0].define(version: 2024_02_27_163855) do
add_foreign_key "administrateurs_instructeurs", "instructeurs" add_foreign_key "administrateurs_instructeurs", "instructeurs"
add_foreign_key "administrateurs_procedures", "administrateurs" add_foreign_key "administrateurs_procedures", "administrateurs"
add_foreign_key "administrateurs_procedures", "procedures" add_foreign_key "administrateurs_procedures", "procedures"
add_foreign_key "agent_connect_informations", "instructeurs"
add_foreign_key "api_tokens", "administrateurs" add_foreign_key "api_tokens", "administrateurs"
add_foreign_key "archives_groupe_instructeurs", "archives" add_foreign_key "archives_groupe_instructeurs", "archives"
add_foreign_key "archives_groupe_instructeurs", "groupe_instructeurs" add_foreign_key "archives_groupe_instructeurs", "groupe_instructeurs"

View file

@ -30,7 +30,7 @@ describe AgentConnect::AgentController, type: :controller do
context 'when the callback code is correct' do context 'when the callback code is correct' do
let(:code) { 'correct' } let(:code) { 'correct' }
let(:state) { original_state } let(:state) { original_state }
let(:user_info) { { 'sub' => 'sub', 'email' => ' I@email.com' } } let(:user_info) { { 'sub' => 'sub', 'email' => ' I@email.com', 'given_name' => 'given', 'usual_name' => 'usual' } }
context 'and user_info returns some info' do context 'and user_info returns some info' do
before do before do

View file

@ -0,0 +1,12 @@
FactoryBot.define do
factory :agent_connect_information do
email { 'i@agent_connect.fr' }
given_name { 'John' }
usual_name { 'Doe' }
sub { '123456789' }
siret { '12345678901234' }
organizational_unit { 'Ministère A.M.E.R.' }
belonging_population { 'stagiaire' }
phone { '0123456789' }
end
end

View file

@ -10,5 +10,11 @@ FactoryBot.define do
email { generate(:instructeur_email) } email { generate(:instructeur_email) }
password { 'somethingverycomplated!' } password { 'somethingverycomplated!' }
end end
trait :with_agent_connect_information do
after(:create) do |instructeur, _evaluator|
create(:agent_connect_information, instructeur: instructeur)
end
end
end end
end end