Skip to content

Commit

Permalink
Merge pull request #9076 from colinux/fix-instructeurs-filter-avis
Browse files Browse the repository at this point in the history
ETQ instructeur je peux filtrer les dossiers par avis
  • Loading branch information
tchak committed May 24, 2023
2 parents 40b3742 + b1435e1 commit cf13b94
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions app/controllers/instructeurs/procedures_controller.rb
Expand Up @@ -314,6 +314,7 @@ def procedure
Procedure
.with_attached_logo
.find(procedure_id)
.tap { Sentry.set_tags(procedure: _1.id) }
end

def ensure_ownership!
Expand Down
4 changes: 2 additions & 2 deletions app/models/procedure_presentation.rb
Expand Up @@ -61,7 +61,7 @@ def fields
field_hash('user', 'email', type: :text),
field_hash('followers_instructeurs', 'email', type: :text),
field_hash('groupe_instructeur', 'id', type: :enum),
field_hash('avis', 'id', type: :text)
field_hash('avis', 'answer', type: :text)
)

if procedure.for_individual
Expand Down Expand Up @@ -211,7 +211,7 @@ def filtered_ids(dossiers, statut)
.includes(:followers_instructeurs)
.joins('INNER JOIN users instructeurs_users ON instructeurs_users.id = instructeurs.user_id')
.filter_ilike('instructeurs_users', :email, values)
when 'user', 'individual'
when 'user', 'individual', 'avis'
dossiers
.includes(table)
.filter_ilike(table, column, values)
Expand Down
2 changes: 1 addition & 1 deletion config/locales/models/procedure_presentation/en.yml
Expand Up @@ -29,7 +29,7 @@ en:
nom: Last name
gender: Title
avis:
id: Opinion
answer: Opinion
etablissement:
entreprise_siren: SIREN
entreprise_forme_juridique: Forme juridique
Expand Down
2 changes: 1 addition & 1 deletion config/locales/models/procedure_presentation/fr.yml
Expand Up @@ -29,7 +29,7 @@ fr:
nom: Nom
gender: Civilité
avis:
id: Avis
answer: Avis
etablissement:
entreprise_siren: SIREN
entreprise_forme_juridique: Forme juridique
Expand Down
15 changes: 14 additions & 1 deletion spec/models/procedure_presentation_spec.rb
Expand Up @@ -73,7 +73,7 @@
{ "label" => 'Demandeur', "table" => 'user', "column" => 'email', 'classname' => '', 'virtual' => false, 'type' => :text, "scope" => '' },
{ "label" => 'Email instructeur', "table" => 'followers_instructeurs', "column" => 'email', 'classname' => '', 'virtual' => false, 'type' => :text, "scope" => '' },
{ "label" => 'Groupe instructeur', "table" => 'groupe_instructeur', "column" => 'id', 'classname' => '', 'virtual' => false, 'type' => :enum, "scope" => '' },
{ "label" => 'Avis', "table" => 'avis', "column" => 'id', 'classname' => '', 'virtual' => false, 'type' => :text, "scope" => '' },
{ "label" => 'Avis', "table" => 'avis', "column" => 'answer', 'classname' => '', 'virtual' => false, 'type' => :text, "scope" => '' },
{ "label" => 'SIREN', "table" => 'etablissement', "column" => 'entreprise_siren', 'classname' => '', 'virtual' => false, 'type' => :text, "scope" => '' },
{ "label" => 'Forme juridique', "table" => 'etablissement', "column" => 'entreprise_forme_juridique', 'classname' => '', 'virtual' => false, 'type' => :text, "scope" => '' },
{ "label" => 'Nom commercial', "table" => 'etablissement', "column" => 'entreprise_nom_commercial', 'classname' => '', 'virtual' => false, 'type' => :text, "scope" => '' },
Expand Down Expand Up @@ -706,6 +706,19 @@
end
end

context 'for avis table' do
let(:procedure) { create(:procedure, :for_individual) }
let!(:kept_dossier) { create(:dossier, procedure:) }
let!(:discarded_dossier) { create(:dossier, procedure:) }
let!(:avis) { create(:avis, :with_answer, dossier: kept_dossier) }

context 'for answer column' do
let(:filter) { [{ 'table' => 'avis', 'column' => 'answer', 'value' => 'Pertinente' }] }

it { is_expected.to contain_exactly(kept_dossier.id) }
end
end

context 'for followers_instructeurs table' do
let(:filter) { [{ 'table' => 'followers_instructeurs', 'column' => 'email', 'value' => 'keepmail' }] }

Expand Down

0 comments on commit cf13b94

Please sign in to comment.