Merge pull request #9704 from mfo/US/fix-procedure-presentation-find-type-de-champ
correctif(instructeurs/procedures/filters): ETQ instructeur, je ne peux filtrer les dossiers d'une procedure par type de champs choix simple
This commit is contained in:
commit
bacd8ab6f7
2 changed files with 17 additions and 1 deletions
|
@ -419,7 +419,7 @@ class ProcedurePresentation < ApplicationRecord
|
|||
TypeDeChamp
|
||||
.joins(:revision_types_de_champ)
|
||||
.where(revision_types_de_champ: { revision_id: procedure.revisions })
|
||||
.order(:created_at)
|
||||
.order(created_at: :desc)
|
||||
.find_by(stable_id: column)
|
||||
end
|
||||
|
||||
|
|
|
@ -994,5 +994,21 @@ describe ProcedurePresentation do
|
|||
|
||||
it { is_expected.to eq([['défaut', procedure.defaut_groupe_instructeur.id], ['gi2', gi_2.id]]) }
|
||||
end
|
||||
|
||||
context 'when field is dropdown' do
|
||||
let(:procedure) { create(:procedure, :published, types_de_champ_public: [{ type: :text }], types_de_champ_private: [{}]) }
|
||||
let(:tdc) { procedure.published_revision.types_de_champ_public.first }
|
||||
before do
|
||||
procedure.draft_revision
|
||||
.find_and_ensure_exclusive_use(tdc.stable_id)
|
||||
.update(type_champ: :drop_down_list,
|
||||
drop_down_list_value: "Paris\nLyon\nMarseille")
|
||||
procedure.publish_revision!
|
||||
end
|
||||
subject { procedure_presentation.field_enum("type_de_champ/#{tdc.id}") }
|
||||
it 'find most recent tdc' do
|
||||
expect(subject).to eq(["Paris", "Lyon", "Marseille"])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue