feat(file retrieval): create agent connect information
This commit is contained in:
parent
4e023ebed0
commit
277ac1259a
7 changed files with 57 additions and 1 deletions
3
app/models/agent_connect_information.rb
Normal file
3
app/models/agent_connect_information.rb
Normal file
|
@ -0,0 +1,3 @@
|
|||
class AgentConnectInformation < ApplicationRecord
|
||||
belongs_to :instructeur
|
||||
end
|
|
@ -2,6 +2,8 @@ class Instructeur < ApplicationRecord
|
|||
include UserFindByConcern
|
||||
has_and_belongs_to_many :administrateurs
|
||||
|
||||
has_one :agent_connect_information, dependent: :destroy
|
||||
|
||||
has_many :assign_to, dependent: :destroy
|
||||
has_many :groupe_instructeurs, -> { order(:label) }, through: :assign_to
|
||||
has_many :unordered_groupe_instructeurs, through: :assign_to, source: :groupe_instructeur
|
||||
|
|
|
@ -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
|
16
db/schema.rb
16
db/schema.rb
|
@ -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"
|
||||
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|
|
||||
t.bigint "administrateur_id", null: false
|
||||
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_procedures", "administrateurs"
|
||||
add_foreign_key "administrateurs_procedures", "procedures"
|
||||
add_foreign_key "agent_connect_informations", "instructeurs"
|
||||
add_foreign_key "api_tokens", "administrateurs"
|
||||
add_foreign_key "archives_groupe_instructeurs", "archives"
|
||||
add_foreign_key "archives_groupe_instructeurs", "groupe_instructeurs"
|
||||
|
|
|
@ -30,7 +30,7 @@ describe AgentConnect::AgentController, type: :controller do
|
|||
context 'when the callback code is correct' do
|
||||
let(:code) { 'correct' }
|
||||
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
|
||||
before do
|
||||
|
|
12
spec/factories/agent_connect_information.rb
Normal file
12
spec/factories/agent_connect_information.rb
Normal 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
|
|
@ -10,5 +10,11 @@ FactoryBot.define do
|
|||
email { generate(:instructeur_email) }
|
||||
password { 'somethingverycomplated!' }
|
||||
end
|
||||
|
||||
trait :with_agent_connect_information do
|
||||
after(:create) do |instructeur, _evaluator|
|
||||
create(:agent_connect_information, instructeur: instructeur)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue