Revision 23585
Added by Marius BĂLTEANU 3 months ago
branches/5.1-stable/config/routes.rb | ||
---|---|---|
313 | 313 |
|
314 | 314 |
# additional routes for having the file name at the end of url |
315 | 315 |
get 'attachments/:id/:filename', :to => 'attachments#show', :id => /\d+/, :filename => /.*/, :as => 'named_attachment', :format => 'html' |
316 |
get 'attachments/download/:id/:filename', :to => 'attachments#download', :id => /\d+/, :filename => /.*/, :as => 'download_named_attachment' |
|
316 |
get 'attachments/download/:id/:filename', :to => 'attachments#download', :id => /\d+/, :filename => /.*/, :as => 'download_named_attachment', :format => 'html'
|
|
317 | 317 |
get 'attachments/download/:id', :to => 'attachments#download', :id => /\d+/ |
318 | 318 |
get 'attachments/thumbnail/:id(/:size)', :to => 'attachments#thumbnail', :id => /\d+/, :size => /\d+/, :as => 'thumbnail' |
319 | 319 |
resources :attachments, :only => [:show, :update, :destroy] |
branches/5.1-stable/test/integration/api_test/attachments_test.rb | ||
---|---|---|
63 | 63 |
|
64 | 64 |
test "GET /attachments/download/:id/:filename should deny access without credentials" do |
65 | 65 |
get '/attachments/download/7/archive.zip' |
66 |
assert_response 401
|
|
66 |
assert_response 302
|
|
67 | 67 |
end |
68 | 68 |
|
69 | 69 |
test "GET /attachments/thumbnail/:id should return the thumbnail" do |
branches/5.1-stable/test/integration/attachments_test.rb | ||
---|---|---|
267 | 267 |
end |
268 | 268 |
end |
269 | 269 |
|
270 |
def test_unauthorized_named_download_link_should_redirect_to_login |
|
271 |
with_settings login_required: '1' do |
|
272 |
get "/attachments/download/1" |
|
273 |
assert_redirected_to "/login?back_url=https%3A%2F%2Fsiteproxy.ruqli.workers.dev%3A443%2Fhttp%2Fwww.example.com%2Fattachments%2Fdownload%2F1" |
|
274 |
|
|
275 |
get "/attachments/download/1/error281.txt" |
|
276 |
assert_redirected_to "/login?back_url=https%3A%2F%2Fsiteproxy.ruqli.workers.dev%3A443%2Fhttp%2Fwww.example.com%2Fattachments%2Fdownload%2F1%2Ferror281.txt" |
|
277 |
end |
|
278 |
end |
|
279 |
|
|
270 | 280 |
private |
271 | 281 |
|
272 | 282 |
def ajax_upload(filename, content, attachment_id=1) |
branches/5.1-stable/test/integration/routing/attachments_test.rb | ||
---|---|---|
26 | 26 |
should_route 'GET /attachments/1/filename.txt' => 'attachments#show', :id => '1', :filename => 'filename.txt', :format => 'html' |
27 | 27 |
|
28 | 28 |
should_route 'GET /attachments/download/1' => 'attachments#download', :id => '1' |
29 |
should_route 'GET /attachments/download/1/filename.ext' => 'attachments#download', :id => '1', :filename => 'filename.ext' |
|
29 |
should_route 'GET /attachments/download/1/filename.ext' => 'attachments#download', :id => '1', :filename => 'filename.ext', :format => 'html'
|
|
30 | 30 |
|
31 | 31 |
should_route 'GET /attachments/thumbnail/1' => 'attachments#thumbnail', :id => '1' |
32 | 32 |
should_route 'GET /attachments/thumbnail/1/200' => 'attachments#thumbnail', :id => '1', :size => '200' |
Also available in: Unified diff
Merged r23581, r23582 and r23583 from trunk to 5.1-stable (#42394).