summaryrefslogtreecommitdiffstats
path: root/test/functional/attachments_controller_test.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-07-07 13:48:07 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-07-07 13:48:07 +0000
commita0c495b953b84d90f5c87f089eaefbf310b9dfeb (patch)
tree80206825ef5f1674b9330aa2688e3bb0d3c48f24 /test/functional/attachments_controller_test.rb
parentb0bd50620195b19dcc1b7f2f82de73fceaa13692 (diff)
downloadredmine-a0c495b953b84d90f5c87f089eaefbf310b9dfeb.tar.gz
redmine-a0c495b953b84d90f5c87f089eaefbf310b9dfeb.zip
Displays thumbnails of attached images of the issue view (#1006).
This behaviour can be turned on/off in Settings -> Display (off by default). Thumbnail size can be configured there too. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9933 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional/attachments_controller_test.rb')
-rw-r--r--test/functional/attachments_controller_test.rb48
1 files changed, 47 insertions, 1 deletions
diff --git a/test/functional/attachments_controller_test.rb b/test/functional/attachments_controller_test.rb
index 487ec5809..949ed3979 100644
--- a/test/functional/attachments_controller_test.rb
+++ b/test/functional/attachments_controller_test.rb
@@ -252,12 +252,58 @@ class AttachmentsControllerTest < ActionController::TestCase
set_tmp_attachments_directory
end
- def test_anonymous_on_private_private
+ def test_download_should_be_denied_without_permission
get :download, :id => 7
assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Fattachments%2Fdownload%2F7'
set_tmp_attachments_directory
end
+ if convert_installed?
+ def test_thumbnail
+ Attachment.clear_thumbnails
+ @request.session[:user_id] = 2
+ with_settings :thumbnails_enabled => '1' do
+ get :thumbnail, :id => 16
+ assert_response :success
+ assert_equal 'image/png', response.content_type
+ end
+ end
+
+ def test_thumbnail_should_return_404_for_non_image_attachment
+ @request.session[:user_id] = 2
+ with_settings :thumbnails_enabled => '1' do
+ get :thumbnail, :id => 15
+ assert_response 404
+ end
+ end
+
+ def test_thumbnail_should_return_404_if_thumbnails_not_enabled
+ @request.session[:user_id] = 2
+ with_settings :thumbnails_enabled => '0' do
+ get :thumbnail, :id => 16
+ assert_response 404
+ end
+ end
+
+ def test_thumbnail_should_return_404_if_thumbnail_generation_failed
+ Attachment.any_instance.stubs(:thumbnail).returns(nil)
+ @request.session[:user_id] = 2
+ with_settings :thumbnails_enabled => '1' do
+ get :thumbnail, :id => 16
+ assert_response 404
+ end
+ end
+
+ def test_thumbnail_should_be_denied_without_permission
+ with_settings :thumbnails_enabled => '1' do
+ get :thumbnail, :id => 16
+ assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Fattachments%2Fthumbnail%2F16'
+ end
+ end
+ else
+ puts '(ImageMagick convert not available)'
+ end
+
def test_destroy_issue_attachment
set_tmp_attachments_directory
issue = Issue.find(3)