Skip to content

Commit

Permalink
chore: dossier controller spec 1
Browse files Browse the repository at this point in the history
  • Loading branch information
yhru committed Dec 10, 2024
1 parent c59f6b6 commit 1c26a5a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@
= render partial: "shared/champs/numero_dn/show", locals: { champ: champ, profile: @profile }
- when TypeDeChamp.type_champs.fetch(:cojo)
= render partial: "shared/champs/cojo/show", locals: { champ: champ, profile: @profile }
- when TypeDeChamp.type_champs.fetch(:lexpol)
= render partial: "shared/champs/lexpol/show", locals: { champ: champ, profile: @profile }
- when TypeDeChamp.type_champs.fetch(:date)
%p= champ.to_s
- when TypeDeChamp.type_champs.fetch(:datetime)
Expand Down
4 changes: 2 additions & 2 deletions app/models/type_de_champ.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class TypeDeChamp < ApplicationRecord
engagement_juridique: :engagement_juridique_type_de_champ,

cojo: :cojo_type_de_champ,
expression_reguliere: :expression_reguliere_type_de_champ
# lexpol: lexpol_champ
expression_reguliere: :expression_reguliere_type_de_champ,
lexpol: :lexpol_type_de_champ
}

MINIMUM_TEXTAREA_CHARACTER_LIMIT_LENGTH = 400
Expand Down
28 changes: 14 additions & 14 deletions app/views/shared/champs/lexpol/_show.html.haml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
- if champ.value.blank?
= form_with url: create_lexpol_dossier_instructeur_dossier_path(dossier_id: champ.dossier.id, champ_id: champ.id), method: :post do |form|
= form.submit 'Créer le dossier dans LexPol', class: 'fr-btn'
- else
%p
%strong Numéro NOR :
= champ.value
%p
%strong Statut du dossier :
= champ.lexpol_status
- if champ.lexpol_dossier_url.present?
= link_to 'Aller sur LexPol', champ.lexpol_dossier_url, target: '_blank', class: 'fr-btn fr-btn--secondary'
= form_with url: update_lexpol_dossier_instructeur_dossier_path(champ.dossier, champ_id: champ.id), method: :post do |form|
= form.submit 'Mettre à jour le dossier', class: 'fr-btn fr-btn--secondary'
-# - if champ.value.blank?
-# = form_with url: create_lexpol_dossier_instructeur_dossier_path(dossier_id: champ.dossier.id, champ_id: champ.id), method: :post do |form|
-# = form.submit 'Créer le dossier dans LexPol', class: 'fr-btn'
-# - else
-# %p
-# %strong Numéro NOR :
-# = champ.value
-# %p
-# %strong Statut du dossier :
-# = champ.lexpol_status
-# - if champ.lexpol_dossier_url.present?
-# = link_to 'Aller sur LexPol', champ.lexpol_dossier_url, target: '_blank', class: 'fr-btn fr-btn--secondary'
-# = form_with url: update_lexpol_dossier_instructeur_dossier_path(champ.dossier, champ_id: champ.id), method: :post do |form|
-# = form.submit 'Mettre à jour le dossier', class: 'fr-btn fr-btn--secondary'
13 changes: 6 additions & 7 deletions spec/controllers/instructeurs/dossiers_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1289,18 +1289,17 @@
let(:instructeur) { create(:instructeur) }
let!(:gi_p1_1) { GroupeInstructeur.create(label: '1', procedure: procedure) }
let!(:procedure) { create(:procedure, :published, :for_individual, instructeurs: [instructeur]) }
let!(:dossier) { create(:dossier, :accepte, :with_individual, procedure: procedure, groupe_instructeur: procedure.groupe_instructeurs.first, hidden_by_administration_at: Time.zone.now) }
let!(:dossier) { create(:dossier, :accepte, :with_individual, procedure: procedure, groupe_instructeur: procedure.groupe_instructeurs.first, hidden_by_administration_at: 1.hour.ago) }
let(:batch_operation) {}
before do
sign_in(instructeur.user)
batch_operation
instructeur.groupe_instructeurs << gi_p1_1
create(:assign_to, instructeur: instructeur, procedure: procedure, groupe_instructeur: dossier.groupe_instructeur)
patch :restore,
params: {
procedure_id: procedure.id,
dossier_id: dossier.id
}
params: {
procedure_id: procedure.id,
dossier_id: dossier.id
}
end

it "puts hidden_by_administration_at to nil" do
Expand All @@ -1309,7 +1308,7 @@

context 'with dossier in batch_operation' do
let(:batch_operation) { create(:batch_operation, operation: :archiver, dossiers: [dossier], instructeur: instructeur) }
it { expect(dossier.reload.hidden_by_administration_at).not_to eq(nil) }
it { expect(dossier.hidden_by_administration_at).not_to eq(nil) }
it { expect(response).to redirect_to(instructeur_dossier_path(dossier.procedure, dossier)) }
it { expect(flash.alert).to eq("Votre action n'a pas été effectuée, ce dossier fait parti d'un traitement de masse.") }
end
Expand Down
10 changes: 0 additions & 10 deletions spec/system/administrateurs/types_de_champ_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,6 @@
expect(page).to have_content('Formulaire enregistré')
end

scenario "adding a lexpol champ and verifying modeles availability" do
add_champ

select('Lexpol', from: 'Type de champ')

fill_in 'Libellé du champ', with: 'Libellé de champ LexPol', fill_options: { clear: :backspace }

expect(page).to have_content('Formulaire enregistré')
end

scenario "adding a piece justificative template" do
add_champ
select('Pièce justificative', from: 'Type de champ')
Expand Down

0 comments on commit 1c26a5a

Please sign in to comment.