Rename :procedure_path -> :path

This commit is contained in:
Paul Chavard 2018-10-30 12:00:58 +01:00
parent f1fd1b38ec
commit 725e88a89a
13 changed files with 31 additions and 31 deletions

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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 lutiliser 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'

View file

@ -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

View file

@ -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

View file

@ -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"

View file

@ -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

View file

@ -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 }

View file

@ -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'

View file

@ -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