##// END OF EJS Templates
Merged r7983 and r7984 from trunk....
Jean-Philippe Lang -
r7880:fa894328bb94
parent child
Show More
@@ -43,6 +43,11 class Version < ActiveRecord::Base
43 user.allowed_to?(:view_issues, self.project)
43 user.allowed_to?(:view_issues, self.project)
44 end
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 def start_date
51 def start_date
47 @start_date ||= fixed_issues.minimum('start_date')
52 @start_date ||= fixed_issues.minimum('start_date')
48 end
53 end
@@ -102,7 +102,7 attachments_009:
102 container_type: Version
102 container_type: Version
103 container_id: 1
103 container_id: 1
104 downloads: 0
104 downloads: 0
105 disk_filename: 060719210727_version_file.zip
105 disk_filename: 060719210727_archive.zip
106 digest: b91e08d0cf966d5c6ff411bd8c4cc3a2
106 digest: b91e08d0cf966d5c6ff411bd8c4cc3a2
107 id: 9
107 id: 9
108 filesize: 452
108 filesize: 452
@@ -104,6 +104,12 class AttachmentsControllerTest < ActionController::TestCase
104 assert_equal 'application/x-ruby', @response.content_type
104 assert_equal 'application/x-ruby', @response.content_type
105 end
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 def test_download_should_assign_content_type_if_blank
113 def test_download_should_assign_content_type_if_blank
108 Attachment.find(4).update_attribute(:content_type, '')
114 Attachment.find(4).update_attribute(:content_type, '')
109
115
@@ -123,6 +129,7 class AttachmentsControllerTest < ActionController::TestCase
123 end
129 end
124
130
125 def test_destroy_issue_attachment
131 def test_destroy_issue_attachment
132 set_tmp_attachments_directory
126 issue = Issue.find(3)
133 issue = Issue.find(3)
127 @request.session[:user_id] = 2
134 @request.session[:user_id] = 2
128
135
@@ -139,6 +146,7 class AttachmentsControllerTest < ActionController::TestCase
139 end
146 end
140
147
141 def test_destroy_wiki_page_attachment
148 def test_destroy_wiki_page_attachment
149 set_tmp_attachments_directory
142 @request.session[:user_id] = 2
150 @request.session[:user_id] = 2
143 assert_difference 'Attachment.count', -1 do
151 assert_difference 'Attachment.count', -1 do
144 post :destroy, :id => 3
152 post :destroy, :id => 3
@@ -147,6 +155,7 class AttachmentsControllerTest < ActionController::TestCase
147 end
155 end
148
156
149 def test_destroy_project_attachment
157 def test_destroy_project_attachment
158 set_tmp_attachments_directory
150 @request.session[:user_id] = 2
159 @request.session[:user_id] = 2
151 assert_difference 'Attachment.count', -1 do
160 assert_difference 'Attachment.count', -1 do
152 post :destroy, :id => 8
161 post :destroy, :id => 8
@@ -155,6 +164,7 class AttachmentsControllerTest < ActionController::TestCase
155 end
164 end
156
165
157 def test_destroy_version_attachment
166 def test_destroy_version_attachment
167 set_tmp_attachments_directory
158 @request.session[:user_id] = 2
168 @request.session[:user_id] = 2
159 assert_difference 'Attachment.count', -1 do
169 assert_difference 'Attachment.count', -1 do
160 post :destroy, :id => 9
170 post :destroy, :id => 9
@@ -163,8 +173,11 class AttachmentsControllerTest < ActionController::TestCase
163 end
173 end
164
174
165 def test_destroy_without_permission
175 def test_destroy_without_permission
166 post :destroy, :id => 3
176 set_tmp_attachments_directory
167 assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Fattachments%2Fdestroy%2F3'
177 assert_no_difference 'Attachment.count' do
178 delete :destroy, :id => 3
179 end
180 assert_response 302
168 assert Attachment.find_by_id(3)
181 assert Attachment.find_by_id(3)
169 end
182 end
170 end
183 end
General Comments 0
You need to be logged in to leave comments. Login now