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