deplacement de l'URL qui envoie vers la procédure

This commit is contained in:
clemkeirua 2019-07-11 11:49:01 +02:00
parent b3db0a104e
commit 6b19432d47
4 changed files with 17 additions and 4 deletions

View file

@ -110,6 +110,8 @@ class Admin::ProceduresController < AdminController
procedure = current_administrateur.procedures.find(params[:procedure_id]) procedure = current_administrateur.procedures.find(params[:procedure_id])
procedure.path = path procedure.path = path
procedure.lien_site_web = params[:lien_site_web]
if !procedure.validate if !procedure.validate
flash.alert = 'Lien de la démarche invalide' flash.alert = 'Lien de la démarche invalide'
return redirect_to admin_procedures_path return redirect_to admin_procedures_path

View file

@ -19,9 +19,10 @@
= f.label :duree_conservation_dossiers_hors_ds, "Hors demarches-simplifiees.fr* (durée en mois après la fin de l'instruction)" = f.label :duree_conservation_dossiers_hors_ds, "Hors demarches-simplifiees.fr* (durée en mois après la fin de l'instruction)"
= f.number_field :duree_conservation_dossiers_hors_ds, class: 'form-control', placeholder: '6', required: true = f.number_field :duree_conservation_dossiers_hors_ds, class: 'form-control', placeholder: '6', required: true
.form-group - if @procedure.locked?
%h4 Où les usagers trouveront-ils le lien vers la démarche ? .form-group
= f.text_field :lien_site_web, class: 'form-control', placeholder: 'https://exemple.gouv.fr/ma_demarche' %h4 Où les usagers trouveront-ils le lien vers la démarche ?
= f.text_field :lien_site_web, class: 'form-control', placeholder: 'https://exemple.gouv.fr/ma_demarche'
.form-group .form-group
%h4 Cadre juridique * %h4 Cadre juridique *

View file

@ -38,6 +38,11 @@
"https://vimeo.com/334463514", "https://vimeo.com/334463514",
target: "_blank" target: "_blank"
.form-group
%h4 Où les usagers trouveront-ils le lien vers cette démarche ?
%p.center
= text_field_tag(:lien_site_web, @procedure.lien_site_web, class: 'form-control', placeholder: 'https://exemple.gouv.fr/ma_demarche')
#path-messages #path-messages
#path_is_mine.text-warning.center.message #path_is_mine.text-warning.center.message
Ce lien est déjà utilisé par une de vos démarche. Ce lien est déjà utilisé par une de vos démarche.

View file

@ -334,10 +334,11 @@ describe Admin::ProceduresController, type: :controller do
let(:procedure) { create(:procedure, administrateur: admin) } let(:procedure) { create(:procedure, administrateur: admin) }
let(:procedure2) { create(:procedure, :published, administrateur: admin) } let(:procedure2) { create(:procedure, :published, administrateur: admin) }
let(:procedure3) { create(:procedure, :published) } let(:procedure3) { create(:procedure, :published) }
let(:lien_site_web) { 'http://some.administration/' }
context 'when admin is the owner of the procedure' do context 'when admin is the owner of the procedure' do
before do before do
put :publish, params: { procedure_id: procedure.id, path: path } put :publish, params: { procedure_id: procedure.id, path: path, lien_site_web: lien_site_web }
procedure.reload procedure.reload
procedure2.reload procedure2.reload
end end
@ -348,6 +349,7 @@ describe Admin::ProceduresController, type: :controller do
it 'publish the given procedure' do it 'publish the given procedure' do
expect(procedure.publiee?).to be_truthy expect(procedure.publiee?).to be_truthy
expect(procedure.path).to eq(path) expect(procedure.path).to eq(path)
expect(procedure.lien_site_web).to eq(lien_site_web)
expect(response.status).to eq 302 expect(response.status).to eq 302
expect(flash[:notice]).to have_content 'Démarche publiée' expect(flash[:notice]).to have_content 'Démarche publiée'
end end
@ -359,6 +361,7 @@ describe Admin::ProceduresController, type: :controller do
it 'publish the given procedure' do it 'publish the given procedure' do
expect(procedure.publiee?).to be_truthy expect(procedure.publiee?).to be_truthy
expect(procedure.path).to eq(path) expect(procedure.path).to eq(path)
expect(procedure.lien_site_web).to eq(lien_site_web)
expect(response.status).to eq 302 expect(response.status).to eq 302
expect(flash[:notice]).to have_content 'Démarche publiée' expect(flash[:notice]).to have_content 'Démarche publiée'
end end
@ -375,6 +378,7 @@ describe Admin::ProceduresController, type: :controller do
it 'does not publish the given procedure' do it 'does not publish the given procedure' do
expect(procedure.publiee?).to be_falsey expect(procedure.publiee?).to be_falsey
expect(procedure.path).not_to match(path) expect(procedure.path).not_to match(path)
expect(procedure.lien_site_web).not_to match(lien_site_web)
expect(response.status).to eq 200 expect(response.status).to eq 200
end end
@ -391,6 +395,7 @@ describe Admin::ProceduresController, type: :controller do
it 'does not publish the given procedure' do it 'does not publish the given procedure' do
expect(procedure.publiee?).to be_falsey expect(procedure.publiee?).to be_falsey
expect(procedure.path).not_to match(path) expect(procedure.path).not_to match(path)
expect(procedure.lien_site_web).not_to match(lien_site_web)
expect(response).to redirect_to :admin_procedures expect(response).to redirect_to :admin_procedures
expect(flash[:alert]).to have_content 'Lien de la démarche invalide' expect(flash[:alert]).to have_content 'Lien de la démarche invalide'
end end