diff --git a/config/routes/redirects.rb b/config/routes/redirects.rb index da7b07b38c..4c6f977ce7 100644 --- a/config/routes/redirects.rb +++ b/config/routes/redirects.rb @@ -39,16 +39,8 @@ get '/request/:id(/*suffix)', constraints: { id: /\d+/, suffix: %r(report/new) }, - 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(widget(/new)?) }, - to: redirect( - -> (params, request) do - redirect_to_info_request_url_title_path(request: request, **params) - end - ) + to: info_request_redirect diff --git a/spec/routing/redirects_spec.rb b/spec/routing/redirects_spec.rb index 6a3cf109ee..bc02d8026c 100644 --- a/spec/routing/redirects_spec.rb +++ b/spec/routing/redirects_spec.rb @@ -17,6 +17,15 @@ it 'routes numerical request member routes to URL title member routes' do get('/request/105/followups/new') expect(response).to redirect_to('/request/the_cost_of_boring/followups/new') + + get('/request/105/report/new') + expect(response).to redirect_to('/request/the_cost_of_boring/report/new') + + get('/request/105/widget') + expect(response).to redirect_to('/request/the_cost_of_boring/widget') + + get('/request/105/widget/new') + expect(response).to redirect_to('/request/the_cost_of_boring/widget/new') end it 'routes numerical request attachment routes to URL title attachment routes' do