Skip to content

Commit

Permalink
fixup! URL Perms: Attachments controller
Browse files Browse the repository at this point in the history
  • Loading branch information
gbp committed Dec 19, 2023
1 parent 4eb7fe8 commit 8630adc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 1 addition & 5 deletions config/routes/redirects.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) },
Expand Down
12 changes: 12 additions & 0 deletions spec/routing/redirects_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 8630adc

Please sign in to comment.