Commit f4180b50557363bc6a7929527dc408c6627ef35f
1 parent
dd287012
Exists in
master
and in
29 other branches
Allowing directly download of images
(ActionItem3131)
Showing
2 changed files
with
16 additions
and
3 deletions
Show diff stats
app/presenters/image.rb
... | ... | @@ -12,7 +12,8 @@ class FilePresenter::Image < FilePresenter |
12 | 12 | _('Image (%s)') % content_type.split('/')[1].upcase |
13 | 13 | end |
14 | 14 | |
15 | - def download? view = nil | |
15 | + #Overwriting method from FilePresenter to allow download of images | |
16 | + def download?(view = nil) | |
16 | 17 | view.blank? || view == 'false' |
17 | 18 | end |
18 | 19 | end | ... | ... |
test/functional/content_viewer_controller_test.rb
... | ... | @@ -75,7 +75,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
75 | 75 | assert_match /#{html.public_filename}/, @response.body |
76 | 76 | end |
77 | 77 | |
78 | - should 'produce a download-link when article is a image' do | |
78 | + should 'download file when article is image' do | |
79 | 79 | profile = create_user('someone').person |
80 | 80 | image = UploadedFile.create! :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :profile => profile |
81 | 81 | image.save! |
... | ... | @@ -84,7 +84,19 @@ class ContentViewerControllerTest < ActionController::TestCase |
84 | 84 | |
85 | 85 | assert_response :success |
86 | 86 | assert_not_nil assigns(:page).data |
87 | - assert_match /image/, @response.headers['Content-Type'] | |
87 | + assert_match /image\/png/, @response.headers['Content-Type'] | |
88 | + end | |
89 | + | |
90 | + should 'display image on a page when article is image and has a view param' do | |
91 | + profile = create_user('someone').person | |
92 | + image = UploadedFile.create! :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :profile => profile | |
93 | + image.save! | |
94 | + | |
95 | + get :view_page, :profile => 'someone', :page => [ 'rails.png' ], :view => true | |
96 | + | |
97 | + assert_response :success | |
98 | + assert_template 'view_page' | |
99 | + assert_match /text\/html/, @response.headers['Content-Type'] | |
88 | 100 | end |
89 | 101 | |
90 | 102 | should 'produce a download-link when article is not text/html' do | ... | ... |