diff --git a/config/routes/redirects.rb b/config/routes/redirects.rb index 7ee0e80f93..da7b07b38c 100644 --- a/config/routes/redirects.rb +++ b/config/routes/redirects.rb @@ -35,11 +35,7 @@ get '/request/:id(/*suffix)', format: false, constraints: { id: /\d+/, suffix: %r(response/\d+/attach(/html)?/\d+/.*) }, - to: redirect( - -> (params, request) do - redirect_to_info_request_url_title_path(request: request, **params) - end - ) + to: info_request_redirect get '/request/:id(/*suffix)', constraints: { id: /\d+/, suffix: %r(report/new) }, diff --git a/spec/routing/redirects_spec.rb b/spec/routing/redirects_spec.rb index f4d94a31ec..6a3cf109ee 100644 --- a/spec/routing/redirects_spec.rb +++ b/spec/routing/redirects_spec.rb @@ -18,4 +18,16 @@ get('/request/105/followups/new') expect(response).to redirect_to('/request/the_cost_of_boring/followups/new') end + + it 'routes numerical request attachment routes to URL title attachment routes' do + get('/request/105/response/1/attach/2/filename.txt') + expect(response).to redirect_to( + '/request/the_cost_of_boring/response/1/attach/2/filename.txt' + ) + + get('/request/105/response/1/attach/html/2/filename.txt.html') + expect(response).to redirect_to( + '/request/the_cost_of_boring/response/1/attach/html/2/filename.txt.html' + ) + end end