@@ -50,6 +50,7 class AttachmentsControllerTest < ActionController::TestCase | |||
|
50 | 50 | :attributes => {:class => /line-code/}, |
|
51 | 51 | :content => /Demande créée avec succès/ |
|
52 | 52 | end |
|
53 | set_tmp_attachments_directory | |
|
53 | 54 | end |
|
54 | 55 | |
|
55 | 56 | def test_show_diff_replcace_cannot_convert_content |
@@ -68,6 +69,7 class AttachmentsControllerTest < ActionController::TestCase | |||
|
68 | 69 | :content => /Demande cr\?\?e avec succ\?s/ |
|
69 | 70 | end |
|
70 | 71 | end |
|
72 | set_tmp_attachments_directory | |
|
71 | 73 | end |
|
72 | 74 | |
|
73 | 75 | def test_show_diff_latin_1 |
@@ -86,6 +88,7 class AttachmentsControllerTest < ActionController::TestCase | |||
|
86 | 88 | :content => /Demande créée avec succès/ |
|
87 | 89 | end |
|
88 | 90 | end |
|
91 | set_tmp_attachments_directory | |
|
89 | 92 | end |
|
90 | 93 | |
|
91 | 94 | def test_show_text_file |
@@ -93,6 +96,7 class AttachmentsControllerTest < ActionController::TestCase | |||
|
93 | 96 | assert_response :success |
|
94 | 97 | assert_template 'file' |
|
95 | 98 | assert_equal 'text/html', @response.content_type |
|
99 | set_tmp_attachments_directory | |
|
96 | 100 | end |
|
97 | 101 | |
|
98 | 102 | def test_show_text_file_utf_8 |
@@ -133,7 +137,7 class AttachmentsControllerTest < ActionController::TestCase | |||
|
133 | 137 | :content => '7', |
|
134 | 138 | :attributes => { :class => 'line-num' }, |
|
135 | 139 | :sibling => { :tag => 'td', :content => /Demande cr\?\?e avec succ\?s/ } |
|
136 |
|
|
|
140 | end | |
|
137 | 141 | end |
|
138 | 142 | |
|
139 | 143 | def test_show_text_file_latin_1 |
@@ -163,17 +167,20 class AttachmentsControllerTest < ActionController::TestCase | |||
|
163 | 167 | get :show, :id => 4 |
|
164 | 168 | assert_response :success |
|
165 | 169 | assert_equal 'application/x-ruby', @response.content_type |
|
170 | set_tmp_attachments_directory | |
|
166 | 171 | end |
|
167 | 172 | |
|
168 | 173 | def test_show_other |
|
169 | 174 | get :show, :id => 6 |
|
170 | 175 | assert_response :success |
|
171 | 176 | assert_equal 'application/octet-stream', @response.content_type |
|
177 | set_tmp_attachments_directory | |
|
172 | 178 | end |
|
173 | 179 | |
|
174 | 180 | def test_show_file_from_private_issue_without_permission |
|
175 | 181 | get :show, :id => 15 |
|
176 | 182 | assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Fattachments%2F15' |
|
183 | set_tmp_attachments_directory | |
|
177 | 184 | end |
|
178 | 185 | |
|
179 | 186 | def test_show_file_from_private_issue_with_permission |
@@ -181,12 +188,14 class AttachmentsControllerTest < ActionController::TestCase | |||
|
181 | 188 | get :show, :id => 15 |
|
182 | 189 | assert_response :success |
|
183 | 190 | assert_tag 'h2', :content => /private.diff/ |
|
191 | set_tmp_attachments_directory | |
|
184 | 192 | end |
|
185 | 193 | |
|
186 | 194 | def test_download_text_file |
|
187 | 195 | get :download, :id => 4 |
|
188 | 196 | assert_response :success |
|
189 | 197 | assert_equal 'application/x-ruby', @response.content_type |
|
198 | set_tmp_attachments_directory | |
|
190 | 199 | end |
|
191 | 200 | |
|
192 | 201 | def test_download_should_assign_content_type_if_blank |
@@ -195,16 +204,19 class AttachmentsControllerTest < ActionController::TestCase | |||
|
195 | 204 | get :download, :id => 4 |
|
196 | 205 | assert_response :success |
|
197 | 206 | assert_equal 'text/x-ruby', @response.content_type |
|
207 | set_tmp_attachments_directory | |
|
198 | 208 | end |
|
199 | 209 | |
|
200 | 210 | def test_download_missing_file |
|
201 | 211 | get :download, :id => 2 |
|
202 | 212 | assert_response 404 |
|
213 | set_tmp_attachments_directory | |
|
203 | 214 | end |
|
204 | 215 | |
|
205 | 216 | def test_anonymous_on_private_private |
|
206 | 217 | get :download, :id => 7 |
|
207 | 218 | assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Fattachments%2Fdownload%2F7' |
|
219 | set_tmp_attachments_directory | |
|
208 | 220 | end |
|
209 | 221 | |
|
210 | 222 | def test_destroy_issue_attachment |
@@ -221,6 +233,7 class AttachmentsControllerTest < ActionController::TestCase | |||
|
221 | 233 | assert_equal 'attachment', j.details.first.property |
|
222 | 234 | assert_equal '1', j.details.first.prop_key |
|
223 | 235 | assert_equal 'error281.txt', j.details.first.old_value |
|
236 | set_tmp_attachments_directory | |
|
224 | 237 | end |
|
225 | 238 | |
|
226 | 239 | def test_destroy_wiki_page_attachment |
@@ -229,6 +242,7 class AttachmentsControllerTest < ActionController::TestCase | |||
|
229 | 242 | post :destroy, :id => 3 |
|
230 | 243 | assert_response 302 |
|
231 | 244 | end |
|
245 | set_tmp_attachments_directory | |
|
232 | 246 | end |
|
233 | 247 | |
|
234 | 248 | def test_destroy_project_attachment |
@@ -237,6 +251,7 class AttachmentsControllerTest < ActionController::TestCase | |||
|
237 | 251 | post :destroy, :id => 8 |
|
238 | 252 | assert_response 302 |
|
239 | 253 | end |
|
254 | set_tmp_attachments_directory | |
|
240 | 255 | end |
|
241 | 256 | |
|
242 | 257 | def test_destroy_version_attachment |
@@ -245,11 +260,13 class AttachmentsControllerTest < ActionController::TestCase | |||
|
245 | 260 | post :destroy, :id => 9 |
|
246 | 261 | assert_response 302 |
|
247 | 262 | end |
|
263 | set_tmp_attachments_directory | |
|
248 | 264 | end |
|
249 | 265 | |
|
250 | 266 | def test_destroy_without_permission |
|
251 | 267 | post :destroy, :id => 3 |
|
252 | 268 | assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Fattachments%2Fdestroy%2F3' |
|
253 | 269 | assert Attachment.find_by_id(3) |
|
270 | set_tmp_attachments_directory | |
|
254 | 271 | end |
|
255 | 272 | end |
@@ -37,7 +37,6 class ApiTest::AttachmentsTest < ActionController::IntegrationTest | |||
|
37 | 37 | context "GET" do |
|
38 | 38 | should "return the attachment" do |
|
39 | 39 | get '/attachments/7.xml', {}, :authorization => credentials('jsmith') |
|
40 | ||
|
41 | 40 | assert_response :success |
|
42 | 41 | assert_equal 'application/xml', @response.content_type |
|
43 | 42 | assert_tag :tag => 'attachment', |
@@ -57,8 +56,8 class ApiTest::AttachmentsTest < ActionController::IntegrationTest | |||
|
57 | 56 | |
|
58 | 57 | should "deny access without credentials" do |
|
59 | 58 | get '/attachments/7.xml' |
|
60 | ||
|
61 | 59 | assert_response 401 |
|
60 | set_tmp_attachments_directory | |
|
62 | 61 | end |
|
63 | 62 | end |
|
64 | 63 | end |
@@ -66,16 +65,17 class ApiTest::AttachmentsTest < ActionController::IntegrationTest | |||
|
66 | 65 | context "/attachments/download/:id/:filename" do |
|
67 | 66 | context "GET" do |
|
68 | 67 | should "return the attachment content" do |
|
69 |
get '/attachments/download/7/archive.zip', |
|
|
70 | ||
|
68 | get '/attachments/download/7/archive.zip', | |
|
69 | {}, :authorization => credentials('jsmith') | |
|
71 | 70 | assert_response :success |
|
72 | 71 | assert_equal 'application/octet-stream', @response.content_type |
|
72 | set_tmp_attachments_directory | |
|
73 | 73 | end |
|
74 | 74 | |
|
75 | 75 | should "deny access without credentials" do |
|
76 | 76 | get '/attachments/download/7/archive.zip' |
|
77 | ||
|
78 | 77 | assert_response 302 |
|
78 | set_tmp_attachments_directory | |
|
79 | 79 | end |
|
80 | 80 | end |
|
81 | 81 | end |
General Comments 0
You need to be logged in to leave comments.
Login now