Fix redirect loop for gestionnaire if hidden procedure is saved in procedure_filter
This commit is contained in:
parent
70c7c42e1f
commit
ce171208da
2 changed files with 16 additions and 3 deletions
|
@ -20,9 +20,13 @@ class Gestionnaire < ActiveRecord::Base
|
|||
include CredentialsSyncableConcern
|
||||
|
||||
def procedure_filter
|
||||
return nil unless assign_to.pluck(:procedure_id).include?(self[:procedure_filter])
|
||||
|
||||
self[:procedure_filter]
|
||||
procedure_id = self[:procedure_filter]
|
||||
if procedures.find_by(id: procedure_id).present?
|
||||
procedure_id
|
||||
else
|
||||
self.update_column(:procedure_filter, nil)
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
def can_view_dossier?(dossier_id)
|
||||
|
|
|
@ -260,6 +260,15 @@ describe Gestionnaire, type: :model do
|
|||
it { expect(AssignTo.where(gestionnaire: gestionnaire, procedure: procedure_3).count).to eq 0 }
|
||||
it { is_expected.to be_nil }
|
||||
end
|
||||
|
||||
context "when procedure is hidden clear procedure_filter" do
|
||||
before do
|
||||
gestionnaire.update_column :procedure_filter, procedure_3.id
|
||||
procedure_3.hide!
|
||||
end
|
||||
|
||||
it { is_expected.to be_nil }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue