diff --git a/app/presenters/image.rb b/app/presenters/image.rb index 8619589..5dee7b9 100644 --- a/app/presenters/image.rb +++ b/app/presenters/image.rb @@ -12,7 +12,8 @@ class FilePresenter::Image < FilePresenter _('Image (%s)') % content_type.split('/')[1].upcase end - def download? view = nil + #Overwriting method from FilePresenter to allow download of images + def download?(view = nil) view.blank? || view == 'false' end end diff --git a/test/functional/content_viewer_controller_test.rb b/test/functional/content_viewer_controller_test.rb index 3006e31..144100c 100644 --- a/test/functional/content_viewer_controller_test.rb +++ b/test/functional/content_viewer_controller_test.rb @@ -75,7 +75,7 @@ class ContentViewerControllerTest < ActionController::TestCase assert_match /#{html.public_filename}/, @response.body end - should 'produce a download-link when article is a image' do + should 'download file when article is image' do profile = create_user('someone').person image = UploadedFile.create! :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :profile => profile image.save! @@ -84,7 +84,19 @@ class ContentViewerControllerTest < ActionController::TestCase assert_response :success assert_not_nil assigns(:page).data - assert_match /image/, @response.headers['Content-Type'] + assert_match /image\/png/, @response.headers['Content-Type'] + end + + should 'display image on a page when article is image and has a view param' do + profile = create_user('someone').person + image = UploadedFile.create! :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :profile => profile + image.save! + + get :view_page, :profile => 'someone', :page => [ 'rails.png' ], :view => true + + assert_response :success + assert_template 'view_page' + assert_match /text\/html/, @response.headers['Content-Type'] end should 'produce a download-link when article is not text/html' do -- libgit2 0.21.2