Defect #42394 » 0001-force-format-to-html-for-the-download_named_attachme.patch
| config/routes.rb | ||
|---|---|---|
|
# additional routes for having the file name at the end of url
|
||
|
get 'attachments/:id/:filename', :to => 'attachments#show', :id => /\d+/, :filename => /.*/, :as => 'named_attachment', :format => 'html'
|
||
|
get 'attachments/download/:id/:filename', :to => 'attachments#download', :id => /\d+/, :filename => /.*/, :as => 'download_named_attachment'
|
||
|
get 'attachments/download/:id/:filename', :to => 'attachments#download', :id => /\d+/, :filename => /.*/, :as => 'download_named_attachment', format: 'html'
|
||
|
get 'attachments/download/:id', :to => 'attachments#download', :id => /\d+/
|
||
|
get 'attachments/thumbnail/:id(/:size)', :to => 'attachments#thumbnail', :id => /\d+/, :size => /\d+/, :as => 'thumbnail'
|
||
|
resources :attachments, :only => [:show, :update, :destroy]
|
||
| test/integration/attachments_test.rb | ||
|---|---|---|
|
end
|
||
|
end
|
||
|
def test_unauthorized_named_download_link_should_redirect_to_login
|
||
|
with_settings login_required: '1' do
|
||
|
get "/attachments/download/1"
|
||
|
assert_redirected_to "/login?back_url=http%3A%2F%2Fwww.example.com%2Fattachments%2Fdownload%2F1"
|
||
|
get "/attachments/download/1/error281.txt"
|
||
|
assert_redirected_to "/login?back_url=http%3A%2F%2Fwww.example.com%2Fattachments%2Fdownload%2F1%2Ferror281.txt"
|
||
|
end
|
||
|
end
|
||
|
private
|
||
|
def ajax_upload(filename, content, attachment_id=1)
|
||