use path_rewrite in commencer controller
This commit is contained in:
parent
516205efd9
commit
6677f31652
3 changed files with 25 additions and 0 deletions
|
@ -4,6 +4,17 @@ module Users
|
|||
class CommencerController < ApplicationController
|
||||
layout 'procedure_context'
|
||||
|
||||
before_action :path_rewrite, only: [:commencer, :commencer_test, :dossier_vide_pdf, :dossier_vide_pdf_test, :sign_in, :sign_up, :france_connect, :procedure_for_help, :closing_details]
|
||||
|
||||
# TODO: REMOVE THIS
|
||||
# this was only added because a administration needed new urls
|
||||
# check from 07/2025 if this is still needed
|
||||
def path_rewrite
|
||||
path_rewrite = PathRewrite.find_by(from: params[:path])
|
||||
|
||||
params[:path] = path_rewrite.to if path_rewrite.present?
|
||||
end
|
||||
|
||||
def commencer
|
||||
@procedure = retrieve_procedure
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreatePathRewrites < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
create_table :path_rewrites do |t|
|
||||
|
|
|
@ -19,6 +19,18 @@ describe Users::CommencerController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when a path rewrite is present' do
|
||||
let(:path) { 'from' }
|
||||
let!(:path_rewrite) { PathRewrite.create(from: 'from', to: published_procedure.path) }
|
||||
|
||||
it 'redirects to the new path' do
|
||||
expect(subject.status).to eq(200)
|
||||
expect(subject).to render_template('show')
|
||||
expect(assigns(:procedure)).to eq published_procedure
|
||||
expect(assigns(:revision)).to eq published_procedure.published_revision
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the path is for a draft procedure' do
|
||||
let(:path) { draft_procedure.path }
|
||||
|
||||
|
|
Loading…
Reference in a new issue