From 725e88a89acc7e3da86aae8eb2e40910c864628a Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Tue, 30 Oct 2018 12:00:58 +0100 Subject: [PATCH] Rename :procedure_path -> :path --- app/controllers/admin/procedures_controller.rb | 2 +- app/controllers/users/dossiers_controller.rb | 4 ++-- app/helpers/procedure_helper.rb | 4 ++-- app/serializers/procedure_serializer.rb | 4 ++-- .../admin/procedures/_informations.html.haml | 2 +- .../admin/procedures/_modal_publish.html.haml | 6 +++--- .../procedure_link_field/_show.html.haml | 2 +- app/views/new_user/demarches/index.html.haml | 4 ++-- config/routes.rb | 4 ++-- .../admin/procedures_controller_spec.rb | 18 +++++++++--------- .../users/dossiers_controller_spec.rb | 4 ++-- .../features/new_user/dossier_creation_spec.rb | 6 +++--- .../admin/procedures/show.html.haml_spec.rb | 2 +- 13 files changed, 31 insertions(+), 31 deletions(-) diff --git a/app/controllers/admin/procedures_controller.rb b/app/controllers/admin/procedures_controller.rb index 94b120fff..5bcc245da 100644 --- a/app/controllers/admin/procedures_controller.rb +++ b/app/controllers/admin/procedures_controller.rb @@ -101,7 +101,7 @@ class Admin::ProceduresController < AdminController end def publish - path = params[:procedure_path] + path = params[:path] procedure = current_administrateur.procedures.find(params[:procedure_id]) procedure.path = path diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb index 9bf7ff033..914c41146 100644 --- a/app/controllers/users/dossiers_controller.rb +++ b/app/controllers/users/dossiers_controller.rb @@ -12,7 +12,7 @@ class Users::DossiersController < UsersController end def commencer_test - procedure = Procedure.brouillons.find_by(path: params[:procedure_path]) + procedure = Procedure.brouillons.find_by(path: params[:path]) if procedure.present? redirect_to new_users_dossier_path(procedure_id: procedure.id, brouillon: true) @@ -23,7 +23,7 @@ class Users::DossiersController < UsersController end def commencer - procedure = Procedure.publiees.find_by(path: params[:procedure_path]) + procedure = Procedure.publiees.find_by(path: params[:path]) if procedure.present? redirect_to new_users_dossier_path(procedure_id: procedure.id) diff --git a/app/helpers/procedure_helper.rb b/app/helpers/procedure_helper.rb index 2f28feed9..4305b05e5 100644 --- a/app/helpers/procedure_helper.rb +++ b/app/helpers/procedure_helper.rb @@ -2,9 +2,9 @@ module ProcedureHelper def procedure_lien(procedure) if procedure.path.present? if procedure.brouillon_avec_lien? - commencer_test_url(procedure_path: procedure.path) + commencer_test_url(path: procedure.path) else - commencer_url(procedure_path: procedure.path) + commencer_url(path: procedure.path) end end end diff --git a/app/serializers/procedure_serializer.rb b/app/serializers/procedure_serializer.rb index 6982cfd84..bd5605a6c 100644 --- a/app/serializers/procedure_serializer.rb +++ b/app/serializers/procedure_serializer.rb @@ -21,9 +21,9 @@ class ProcedureSerializer < ActiveModel::Serializer def link if object.path.present? if object.brouillon_avec_lien? - commencer_test_url(procedure_path: object.path) + commencer_test_url(path: object.path) else - commencer_url(procedure_path: object.path) + commencer_url(path: object.path) end end end diff --git a/app/views/admin/procedures/_informations.html.haml b/app/views/admin/procedures/_informations.html.haml index 6650fa034..77b53632d 100644 --- a/app/views/admin/procedures/_informations.html.haml +++ b/app/views/admin/procedures/_informations.html.haml @@ -16,7 +16,7 @@ %h4 Lien public* .procedure-lien %span.prefix - = commencer_test_url(procedure_path: '') + = commencer_test_url(path: '') = f.text_field :path, value: @path, class: 'form-control', data: { remote: true, debounce: true, url: admin_procedures_available_path, params: { id: @procedure.id }.to_query(:procedure) } %p.unavailable-path-message.text-warning - if !@available diff --git a/app/views/admin/procedures/_modal_publish.html.haml b/app/views/admin/procedures/_modal_publish.html.haml index 2109792ae..0508ff880 100644 --- a/app/views/admin/procedures/_modal_publish.html.haml +++ b/app/views/admin/procedures/_modal_publish.html.haml @@ -20,8 +20,8 @@ %br %h4 Lien de la démarche %p.center - = commencer_url(procedure_path: '') - = text_field_tag('procedure_path', @procedure.path || @procedure.default_path, + = commencer_url(path: '') + = text_field_tag(:path, @procedure.path || @procedure.default_path, id: 'procedure_path', placeholder: 'Chemin vers la démarche', data: { autocomplete: 'path' }, @@ -41,7 +41,7 @@ %br Vous ne pouvez pas l’utiliser car il appartient à un autre administrateur. #path_is_invalid.text-danger.center.message - = t('activerecord.errors.models.procedure_path.attributes.path.format') + = t('activerecord.errors.models.procedure.attributes.path.format') .modal-footer = submit_tag procedure_modal_text(@procedure, :submit), class: %w(btn btn btn-success), disabled: :disabled, id: 'publish' = button_tag "Annuler", class: %w(btn btn btn-default), data: { dismiss: :modal }, id: 'cancel' diff --git a/app/views/fields/procedure_link_field/_show.html.haml b/app/views/fields/procedure_link_field/_show.html.haml index 250a02c4f..7d0ee3413 100644 --- a/app/views/fields/procedure_link_field/_show.html.haml +++ b/app/views/fields/procedure_link_field/_show.html.haml @@ -1,4 +1,4 @@ - if field.data.present? - = link_to "/commencer/#{field.data}", commencer_url(procedure_path: field.data), target: '_blank' + = link_to "/commencer/#{field.data}", commencer_url(path: field.data), target: '_blank' - else Plus en ligne diff --git a/app/views/new_user/demarches/index.html.haml b/app/views/new_user/demarches/index.html.haml index 334471b7b..0767a4b04 100644 --- a/app/views/new_user/demarches/index.html.haml +++ b/app/views/new_user/demarches/index.html.haml @@ -12,7 +12,7 @@ %ul.demarche-links - @previous_demarches_still_active.each do |demarche| %li - = link_to(commencer_url(procedure_path: demarche.path), class: "demarche-link") do + = link_to(commencer_url(path: demarche.path), class: "demarche-link") do = demarche.libelle %br .service-name @@ -23,7 +23,7 @@ %ul.demarche-links - @popular_demarches.each do |demarche| %li - = link_to(commencer_url(procedure_path: demarche.path), class: "demarche-link") do + = link_to(commencer_url(path: demarche.path), class: "demarche-link") do = demarche.libelle %br .service-name diff --git a/config/routes.rb b/config/routes.rb index 8479addd8..0b520e22f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -129,8 +129,8 @@ Rails.application.routes.draw do end namespace :commencer do - get '/test/:procedure_path' => '/users/dossiers#commencer_test', as: :test - get '/:procedure_path' => '/users/dossiers#commencer' + get '/test/:path' => '/users/dossiers#commencer_test', as: :test + get '/:path' => '/users/dossiers#commencer' end get "patron" => "root#patron" diff --git a/spec/controllers/admin/procedures_controller_spec.rb b/spec/controllers/admin/procedures_controller_spec.rb index bf4cfcb1d..1f01f11b4 100644 --- a/spec/controllers/admin/procedures_controller_spec.rb +++ b/spec/controllers/admin/procedures_controller_spec.rb @@ -359,28 +359,28 @@ describe Admin::ProceduresController, type: :controller do context 'when admin is the owner of the procedure' do before do - put :publish, params: { procedure_id: procedure.id, procedure_path: procedure_path } + put :publish, params: { procedure_id: procedure.id, path: path } procedure.reload procedure2.reload end context 'procedure path does not exist' do - let(:procedure_path) { 'new_path' } + let(:path) { 'new_path' } it 'publish the given procedure' do expect(procedure.publiee?).to be_truthy - expect(procedure.path).to eq(procedure_path) + expect(procedure.path).to eq(path) expect(response.status).to eq 302 expect(flash[:notice]).to have_content 'Démarche publiée' end end context 'procedure path exists and is owned by current administrator' do - let(:procedure_path) { procedure2.path } + let(:path) { procedure2.path } it 'publish the given procedure' do expect(procedure.publiee?).to be_truthy - expect(procedure.path).to eq(procedure_path) + expect(procedure.path).to eq(path) expect(response.status).to eq 302 expect(flash[:notice]).to have_content 'Démarche publiée' end @@ -392,7 +392,7 @@ describe Admin::ProceduresController, type: :controller do end context 'procedure path exists and is not owned by current administrator' do - let(:procedure_path) { procedure3.path } + let(:path) { procedure3.path } it 'does not publish the given procedure' do expect(procedure.publiee?).to be_falsey @@ -408,7 +408,7 @@ describe Admin::ProceduresController, type: :controller do end context 'procedure path is invalid' do - let(:procedure_path) { 'Invalid Procedure Path' } + let(:path) { 'Invalid Procedure Path' } it 'does not publish the given procedure' do expect(procedure.publiee?).to be_falsey @@ -426,7 +426,7 @@ describe Admin::ProceduresController, type: :controller do sign_out admin sign_in admin_2 - put :publish, params: { procedure_id: procedure.id, procedure_path: 'fake_path' } + put :publish, params: { procedure_id: procedure.id, path: 'fake_path' } procedure.reload end @@ -454,7 +454,7 @@ describe Admin::ProceduresController, type: :controller do context 'when owner want to re-enable procedure' do before do - put :publish, params: { procedure_id: procedure.id, procedure_path: 'fake_path' } + put :publish, params: { procedure_id: procedure.id, path: 'fake_path' } procedure.reload end diff --git a/spec/controllers/users/dossiers_controller_spec.rb b/spec/controllers/users/dossiers_controller_spec.rb index 5bfa1dd45..f323d0f3f 100644 --- a/spec/controllers/users/dossiers_controller_spec.rb +++ b/spec/controllers/users/dossiers_controller_spec.rb @@ -65,7 +65,7 @@ describe Users::DossiersController, type: :controller do end describe 'GET #commencer' do - subject { get :commencer, params: { procedure_path: path } } + subject { get :commencer, params: { path: path } } let(:path) { procedure.path } it { expect(subject.status).to eq 302 } @@ -83,7 +83,7 @@ describe Users::DossiersController, type: :controller do Flipflop::FeatureSet.current.test!.switch!(:publish_draft, true) end - subject { get :commencer_test, params: { procedure_path: path } } + subject { get :commencer_test, params: { path: path } } let(:procedure) { create(:procedure, :with_path) } let(:path) { procedure.path } diff --git a/spec/features/new_user/dossier_creation_spec.rb b/spec/features/new_user/dossier_creation_spec.rb index 6c468745a..84fc98621 100644 --- a/spec/features/new_user/dossier_creation_spec.rb +++ b/spec/features/new_user/dossier_creation_spec.rb @@ -16,7 +16,7 @@ feature 'Creating a new dossier:' do let(:expected_birthday) { nil } before do - visit commencer_path(procedure_path: procedure.path) + visit commencer_path(path: procedure.path) fill_in 'individual_nom', with: 'Nom' fill_in 'individual_prenom', with: 'Prenom' end @@ -76,7 +76,7 @@ feature 'Creating a new dossier:' do end scenario 'the user can enter the SIRET of its etablissement and create a new draft', vcr: { cassette_name: 'api_adresse_search_paris_3' }, js: true do - visit commencer_path(procedure_path: procedure.path) + visit commencer_path(path: procedure.path) expect(page).to have_current_path(siret_dossier_path(dossier)) fill_in 'Numéro SIRET', with: siret @@ -93,7 +93,7 @@ feature 'Creating a new dossier:' do end scenario 'the user is notified when its SIRET is invalid' do - visit commencer_path(procedure_path: procedure.path) + visit commencer_path(path: procedure.path) expect(page).to have_current_path(siret_dossier_path(dossier)) fill_in 'Numéro SIRET', with: '0000' diff --git a/spec/views/admin/procedures/show.html.haml_spec.rb b/spec/views/admin/procedures/show.html.haml_spec.rb index c44f748cb..1418c389b 100644 --- a/spec/views/admin/procedures/show.html.haml_spec.rb +++ b/spec/views/admin/procedures/show.html.haml_spec.rb @@ -53,7 +53,7 @@ describe 'admin/procedures/show.html.haml', type: :view do end describe 'procedure link is present' do - it { expect(rendered).to have_content(commencer_url(procedure_path: procedure.path)) } + it { expect(rendered).to have_content(commencer_url(path: procedure.path)) } end end