From fa894328bb944e1b2f88295f0b6a465f1ac3eaf5 2011-11-29 21:17:41 From: Jean-Philippe Lang Date: 2011-11-29 21:17:41 Subject: [PATCH] Merged r7983 and r7984 from trunk. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.2-stable@8000 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/models/version.rb b/app/models/version.rb index 710074a..b79d363 100644 --- a/app/models/version.rb +++ b/app/models/version.rb @@ -43,6 +43,11 @@ class Version < ActiveRecord::Base user.allowed_to?(:view_issues, self.project) end + # Version files have same visibility as project files + def attachments_visible?(*args) + project.present? && project.attachments_visible?(*args) + end + def start_date @start_date ||= fixed_issues.minimum('start_date') end diff --git a/test/fixtures/attachments.yml b/test/fixtures/attachments.yml index 438e212..fba1553 100644 --- a/test/fixtures/attachments.yml +++ b/test/fixtures/attachments.yml @@ -102,7 +102,7 @@ attachments_009: container_type: Version container_id: 1 downloads: 0 - disk_filename: 060719210727_version_file.zip + disk_filename: 060719210727_archive.zip digest: b91e08d0cf966d5c6ff411bd8c4cc3a2 id: 9 filesize: 452 diff --git a/test/functional/attachments_controller_test.rb b/test/functional/attachments_controller_test.rb index e609299..c6ae2dd 100644 --- a/test/functional/attachments_controller_test.rb +++ b/test/functional/attachments_controller_test.rb @@ -104,6 +104,12 @@ class AttachmentsControllerTest < ActionController::TestCase assert_equal 'application/x-ruby', @response.content_type end + def test_download_version_file_with_issue_tracking_disabled + Project.find(1).disable_module! :issue_tracking + get :download, :id => 9 + assert_response :success + end + def test_download_should_assign_content_type_if_blank Attachment.find(4).update_attribute(:content_type, '') @@ -123,6 +129,7 @@ class AttachmentsControllerTest < ActionController::TestCase end def test_destroy_issue_attachment + set_tmp_attachments_directory issue = Issue.find(3) @request.session[:user_id] = 2 @@ -139,6 +146,7 @@ class AttachmentsControllerTest < ActionController::TestCase end def test_destroy_wiki_page_attachment + set_tmp_attachments_directory @request.session[:user_id] = 2 assert_difference 'Attachment.count', -1 do post :destroy, :id => 3 @@ -147,6 +155,7 @@ class AttachmentsControllerTest < ActionController::TestCase end def test_destroy_project_attachment + set_tmp_attachments_directory @request.session[:user_id] = 2 assert_difference 'Attachment.count', -1 do post :destroy, :id => 8 @@ -155,6 +164,7 @@ class AttachmentsControllerTest < ActionController::TestCase end def test_destroy_version_attachment + set_tmp_attachments_directory @request.session[:user_id] = 2 assert_difference 'Attachment.count', -1 do post :destroy, :id => 9 @@ -163,8 +173,11 @@ class AttachmentsControllerTest < ActionController::TestCase end def test_destroy_without_permission - post :destroy, :id => 3 - assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Fattachments%2Fdestroy%2F3' + set_tmp_attachments_directory + assert_no_difference 'Attachment.count' do + delete :destroy, :id => 3 + end + assert_response 302 assert Attachment.find_by_id(3) end end