From 72790af069f65a3a0ab0113d0a7ac2fa99322d0a Mon Sep 17 00:00:00 2001 From: Arthur Del Esposte Date: Fri, 6 Jun 2014 11:48:14 -0300 Subject: [PATCH] AI3131 - fixing bug in add image to articles, header and footer --- app/presenters/image.rb | 4 ++++ test/functional/content_viewer_controller_test.rb | 12 ++++++++++++ 2 files changed, 16 insertions(+), 0 deletions(-) diff --git a/app/presenters/image.rb b/app/presenters/image.rb index 23d4da7..8619589 100644 --- a/app/presenters/image.rb +++ b/app/presenters/image.rb @@ -11,4 +11,8 @@ class FilePresenter::Image < FilePresenter def short_description _('Image (%s)') % content_type.split('/')[1].upcase end + + 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 61628bb..3006e31 100644 --- a/test/functional/content_viewer_controller_test.rb +++ b/test/functional/content_viewer_controller_test.rb @@ -75,6 +75,18 @@ class ContentViewerControllerTest < ActionController::TestCase assert_match /#{html.public_filename}/, @response.body end + should 'produce a download-link when article is a image' 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' ] + + assert_response :success + assert_not_nil assigns(:page).data + assert_match /image/, @response.headers['Content-Type'] + end + should 'produce a download-link when article is not text/html' do # for example, RSS feeds -- libgit2 0.21.2