Commit f4180b50557363bc6a7929527dc408c6627ef35f

Authored by Daniela Feitosa
1 parent dd287012

Allowing directly download of images

(ActionItem3131)
app/presenters/image.rb
@@ -12,7 +12,8 @@ class FilePresenter::Image < FilePresenter @@ -12,7 +12,8 @@ class FilePresenter::Image < FilePresenter
12 _('Image (%s)') % content_type.split('/')[1].upcase 12 _('Image (%s)') % content_type.split('/')[1].upcase
13 end 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 view.blank? || view == 'false' 17 view.blank? || view == 'false'
17 end 18 end
18 end 19 end
test/functional/content_viewer_controller_test.rb
@@ -75,7 +75,7 @@ class ContentViewerControllerTest < ActionController::TestCase @@ -75,7 +75,7 @@ class ContentViewerControllerTest < ActionController::TestCase
75 assert_match /#{html.public_filename}/, @response.body 75 assert_match /#{html.public_filename}/, @response.body
76 end 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 profile = create_user('someone').person 79 profile = create_user('someone').person
80 image = UploadedFile.create! :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :profile => profile 80 image = UploadedFile.create! :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :profile => profile
81 image.save! 81 image.save!
@@ -84,7 +84,19 @@ class ContentViewerControllerTest < ActionController::TestCase @@ -84,7 +84,19 @@ class ContentViewerControllerTest < ActionController::TestCase
84 84
85 assert_response :success 85 assert_response :success
86 assert_not_nil assigns(:page).data 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 end 100 end
89 101
90 should 'produce a download-link when article is not text/html' do 102 should 'produce a download-link when article is not text/html' do