@@ -43,6 +43,11 class Version < ActiveRecord::Base | |||
|
43 | 43 | user.allowed_to?(:view_issues, self.project) |
|
44 | 44 | end |
|
45 | 45 | |
|
46 | # Version files have same visibility as project files | |
|
47 | def attachments_visible?(*args) | |
|
48 | project.present? && project.attachments_visible?(*args) | |
|
49 | end | |
|
50 | ||
|
46 | 51 | def start_date |
|
47 | 52 | @start_date ||= fixed_issues.minimum('start_date') |
|
48 | 53 | end |
@@ -102,7 +102,7 attachments_009: | |||
|
102 | 102 | container_type: Version |
|
103 | 103 | container_id: 1 |
|
104 | 104 | downloads: 0 |
|
105 |
disk_filename: 060719210727_ |
|
|
105 | disk_filename: 060719210727_archive.zip | |
|
106 | 106 | digest: b91e08d0cf966d5c6ff411bd8c4cc3a2 |
|
107 | 107 | id: 9 |
|
108 | 108 | filesize: 452 |
@@ -104,6 +104,12 class AttachmentsControllerTest < ActionController::TestCase | |||
|
104 | 104 | assert_equal 'application/x-ruby', @response.content_type |
|
105 | 105 | end |
|
106 | 106 | |
|
107 | def test_download_version_file_with_issue_tracking_disabled | |
|
108 | Project.find(1).disable_module! :issue_tracking | |
|
109 | get :download, :id => 9 | |
|
110 | assert_response :success | |
|
111 | end | |
|
112 | ||
|
107 | 113 | def test_download_should_assign_content_type_if_blank |
|
108 | 114 | Attachment.find(4).update_attribute(:content_type, '') |
|
109 | 115 | |
@@ -123,6 +129,7 class AttachmentsControllerTest < ActionController::TestCase | |||
|
123 | 129 | end |
|
124 | 130 | |
|
125 | 131 | def test_destroy_issue_attachment |
|
132 | set_tmp_attachments_directory | |
|
126 | 133 | issue = Issue.find(3) |
|
127 | 134 | @request.session[:user_id] = 2 |
|
128 | 135 | |
@@ -139,6 +146,7 class AttachmentsControllerTest < ActionController::TestCase | |||
|
139 | 146 | end |
|
140 | 147 | |
|
141 | 148 | def test_destroy_wiki_page_attachment |
|
149 | set_tmp_attachments_directory | |
|
142 | 150 | @request.session[:user_id] = 2 |
|
143 | 151 | assert_difference 'Attachment.count', -1 do |
|
144 | 152 | post :destroy, :id => 3 |
@@ -147,6 +155,7 class AttachmentsControllerTest < ActionController::TestCase | |||
|
147 | 155 | end |
|
148 | 156 | |
|
149 | 157 | def test_destroy_project_attachment |
|
158 | set_tmp_attachments_directory | |
|
150 | 159 | @request.session[:user_id] = 2 |
|
151 | 160 | assert_difference 'Attachment.count', -1 do |
|
152 | 161 | post :destroy, :id => 8 |
@@ -155,6 +164,7 class AttachmentsControllerTest < ActionController::TestCase | |||
|
155 | 164 | end |
|
156 | 165 | |
|
157 | 166 | def test_destroy_version_attachment |
|
167 | set_tmp_attachments_directory | |
|
158 | 168 | @request.session[:user_id] = 2 |
|
159 | 169 | assert_difference 'Attachment.count', -1 do |
|
160 | 170 | post :destroy, :id => 9 |
@@ -163,8 +173,11 class AttachmentsControllerTest < ActionController::TestCase | |||
|
163 | 173 | end |
|
164 | 174 | |
|
165 | 175 | def test_destroy_without_permission |
|
166 | post :destroy, :id => 3 | |
|
167 | assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Fattachments%2Fdestroy%2F3' | |
|
176 | set_tmp_attachments_directory | |
|
177 | assert_no_difference 'Attachment.count' do | |
|
178 | delete :destroy, :id => 3 | |
|
179 | end | |
|
180 | assert_response 302 | |
|
168 | 181 | assert Attachment.find_by_id(3) |
|
169 | 182 | end |
|
170 | 183 | end |
General Comments 0
You need to be logged in to leave comments.
Login now