Link assign_to and procedure by groupe_instructeur
This commit is contained in:
parent
4da12ed3e8
commit
ad7ef6c739
4 changed files with 4 additions and 4 deletions
|
@ -212,7 +212,7 @@ module Instructeurs
|
||||||
end
|
end
|
||||||
|
|
||||||
def assign_to
|
def assign_to
|
||||||
current_instructeur.assign_to.find_by(procedure: procedure)
|
current_instructeur.assign_to.joins(:groupe_instructeur).find_by(groupe_instructeurs: { procedure: procedure })
|
||||||
end
|
end
|
||||||
|
|
||||||
def statut
|
def statut
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
class AssignTo < ApplicationRecord
|
class AssignTo < ApplicationRecord
|
||||||
belongs_to :procedure
|
|
||||||
belongs_to :instructeur
|
belongs_to :instructeur
|
||||||
belongs_to :groupe_instructeur
|
belongs_to :groupe_instructeur
|
||||||
has_one :procedure_presentation, dependent: :destroy
|
has_one :procedure_presentation, dependent: :destroy
|
||||||
|
has_one :procedure, through: :groupe_instructeur
|
||||||
|
|
||||||
scope :with_email_notifications, -> { where(email_notifications_enabled: true) }
|
scope :with_email_notifications, -> { where(email_notifications_enabled: true) }
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ class Instructeur < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def procedure_presentation_and_errors_for_procedure_id(procedure_id)
|
def procedure_presentation_and_errors_for_procedure_id(procedure_id)
|
||||||
assign_to.find_by(procedure_id: procedure_id).procedure_presentation_or_default_and_errors
|
assign_to.joins(:groupe_instructeur).find_by(groupe_instructeurs: { procedure_id: procedure_id }).procedure_presentation_or_default_and_errors
|
||||||
end
|
end
|
||||||
|
|
||||||
def notifications_for_dossier(dossier)
|
def notifications_for_dossier(dossier)
|
||||||
|
|
|
@ -347,7 +347,7 @@ describe Instructeurs::ProceduresController, type: :controller do
|
||||||
it { expect(instructeur.groupe_instructeur_with_email_notifications).to be_empty }
|
it { expect(instructeur.groupe_instructeur_with_email_notifications).to be_empty }
|
||||||
|
|
||||||
context 'when the instructeur update its preferences' do
|
context 'when the instructeur update its preferences' do
|
||||||
let(:assign_to) { instructeur.assign_to.find_by(procedure: procedure) }
|
let(:assign_to) { instructeur.assign_to.joins(:groupe_instructeur).find_by(groupe_instructeurs: { procedure: procedure }) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
patch :update_email_notifications, params: { procedure_id: procedure.id, assign_to: { id: assign_to.id, email_notifications_enabled: true } }
|
patch :update_email_notifications, params: { procedure_id: procedure.id, assign_to: { id: assign_to.id, email_notifications_enabled: true } }
|
||||||
|
|
Loading…
Add table
Reference in a new issue