@@ -53,7 +53,7 class AttachmentsController < ApplicationController | |||
|
53 | 53 | |
|
54 | 54 | end |
|
55 | 55 | |
|
56 |
verify :method => : |
|
|
56 | verify :method => :delete, :only => :destroy | |
|
57 | 57 | def destroy |
|
58 | 58 | # Make sure association callbacks are called |
|
59 | 59 | @attachment.container.attachments.delete(@attachment) |
@@ -4,9 +4,9 | |||
|
4 | 4 | <%= h(" - #{attachment.description}") unless attachment.description.blank? %> |
|
5 | 5 | <span class="size">(<%= number_to_human_size attachment.filesize %>)</span> |
|
6 | 6 | <% if options[:deletable] %> |
|
7 |
<%= link_to image_tag('delete.png'), |
|
|
7 | <%= link_to image_tag('delete.png'), attachment_path(attachment), | |
|
8 | 8 | :confirm => l(:text_are_you_sure), |
|
9 |
:method => : |
|
|
9 | :method => :delete, | |
|
10 | 10 | :class => 'delete', |
|
11 | 11 | :title => l(:button_delete) %> |
|
12 | 12 | <% end %> |
@@ -33,8 +33,8 | |||
|
33 | 33 | <td class="downloads"><%= file.downloads %></td> |
|
34 | 34 | <td class="digest"><%= file.digest %></td> |
|
35 | 35 | <td align="center"> |
|
36 |
<%= link_to(image_tag('delete.png'), |
|
|
37 |
:confirm => l(:text_are_you_sure), :method => : |
|
|
36 | <%= link_to(image_tag('delete.png'), attachment_path(file), | |
|
37 | :confirm => l(:text_are_you_sure), :method => :delete) if delete_allowed %> | |
|
38 | 38 | </td> |
|
39 | 39 | </tr> |
|
40 | 40 | <% end |
@@ -215,9 +215,9 ActionController::Routing::Routes.draw do |map| | |||
|
215 | 215 | |
|
216 | 216 | repositories.connect 'projects/:id/repository/:action', :conditions => {:method => :post} |
|
217 | 217 | end |
|
218 | ||
|
219 | map.connect 'attachments/:id', :controller => 'attachments', :action => 'show', :id => /\d+/ | |
|
220 | map.connect 'attachments/:id.:format', :controller => 'attachments', :action => 'show', :id => /\d+/ | |
|
218 | ||
|
219 | map.resources :attachments, :only => [:show, :destroy] | |
|
220 | # additional routes for having the file name at the end of url | |
|
221 | 221 | map.connect 'attachments/:id/:filename', :controller => 'attachments', :action => 'show', :id => /\d+/, :filename => /.*/ |
|
222 | 222 | map.connect 'attachments/download/:id/:filename', :controller => 'attachments', :action => 'download', :id => /\d+/, :filename => /.*/ |
|
223 | 223 |
@@ -224,7 +224,7 class AttachmentsControllerTest < ActionController::TestCase | |||
|
224 | 224 | @request.session[:user_id] = 2 |
|
225 | 225 | |
|
226 | 226 | assert_difference 'issue.attachments.count', -1 do |
|
227 |
|
|
|
227 | delete :destroy, :id => 1 | |
|
228 | 228 | end |
|
229 | 229 | # no referrer |
|
230 | 230 | assert_redirected_to '/projects/ecookbook' |
@@ -239,7 +239,7 class AttachmentsControllerTest < ActionController::TestCase | |||
|
239 | 239 | def test_destroy_wiki_page_attachment |
|
240 | 240 | @request.session[:user_id] = 2 |
|
241 | 241 | assert_difference 'Attachment.count', -1 do |
|
242 |
|
|
|
242 | delete :destroy, :id => 3 | |
|
243 | 243 | assert_response 302 |
|
244 | 244 | end |
|
245 | 245 | set_tmp_attachments_directory |
@@ -248,7 +248,7 class AttachmentsControllerTest < ActionController::TestCase | |||
|
248 | 248 | def test_destroy_project_attachment |
|
249 | 249 | @request.session[:user_id] = 2 |
|
250 | 250 | assert_difference 'Attachment.count', -1 do |
|
251 |
|
|
|
251 | delete :destroy, :id => 8 | |
|
252 | 252 | assert_response 302 |
|
253 | 253 | end |
|
254 | 254 | set_tmp_attachments_directory |
@@ -257,15 +257,17 class AttachmentsControllerTest < ActionController::TestCase | |||
|
257 | 257 | def test_destroy_version_attachment |
|
258 | 258 | @request.session[:user_id] = 2 |
|
259 | 259 | assert_difference 'Attachment.count', -1 do |
|
260 |
|
|
|
260 | delete :destroy, :id => 9 | |
|
261 | 261 | assert_response 302 |
|
262 | 262 | end |
|
263 | 263 | set_tmp_attachments_directory |
|
264 | 264 | end |
|
265 | 265 | |
|
266 | 266 | def test_destroy_without_permission |
|
267 | post :destroy, :id => 3 | |
|
268 | assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Fattachments%2Fdestroy%2F3' | |
|
267 | assert_no_difference 'Attachment.count' do | |
|
268 | delete :destroy, :id => 3 | |
|
269 | end | |
|
270 | assert_response 302 | |
|
269 | 271 | assert Attachment.find_by_id(3) |
|
270 | 272 | set_tmp_attachments_directory |
|
271 | 273 | end |
General Comments 0
You need to be logged in to leave comments.
Login now