@@ -228,18 +228,15 class ProjectsController < ApplicationController | |||
|
228 | 228 | redirect_to(url_for(:controller => 'admin', :action => 'projects', :status => params[:status])) |
|
229 | 229 | end |
|
230 | 230 | |
|
231 | verify :method => :delete, :only => :destroy, :render => {:nothing => true, :status => :method_not_allowed } | |
|
231 | 232 | # Delete @project |
|
232 | 233 | def destroy |
|
233 | 234 | @project_to_destroy = @project |
|
234 | if request.get? | |
|
235 | # display confirmation view | |
|
236 | else | |
|
237 | if api_request? || params[:confirm] | |
|
238 | @project_to_destroy.destroy | |
|
239 | respond_to do |format| | |
|
240 | format.html { redirect_to :controller => 'admin', :action => 'projects' } | |
|
241 | format.api { head :ok } | |
|
242 | end | |
|
235 | if api_request? || params[:confirm] | |
|
236 | @project_to_destroy.destroy | |
|
237 | respond_to do |format| | |
|
238 | format.html { redirect_to :controller => 'admin', :action => 'projects' } | |
|
239 | format.api { head :ok } | |
|
243 | 240 | end |
|
244 | 241 | end |
|
245 | 242 | # hide project in layout |
@@ -34,7 +34,7 | |||
|
34 | 34 | <%= link_to(l(:button_archive), { :controller => 'projects', :action => 'archive', :id => project, :status => params[:status] }, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-lock') if project.active? %> |
|
35 | 35 | <%= link_to(l(:button_unarchive), { :controller => 'projects', :action => 'unarchive', :id => project, :status => params[:status] }, :method => :post, :class => 'icon icon-unlock') if !project.active? && (project.parent.nil? || project.parent.active?) %> |
|
36 | 36 | <%= link_to(l(:button_copy), { :controller => 'projects', :action => 'copy', :id => project }, :class => 'icon icon-copy') %> |
|
37 |
<%= link_to(l(:button_delete), project_ |
|
|
37 | <%= link_to(l(:button_delete), project_path(project), :method => :delete, :class => 'icon icon-del') %> | |
|
38 | 38 | </td> |
|
39 | 39 | </tr> |
|
40 | 40 | <% end %> |
@@ -125,9 +125,6 ActionController::Routing::Routes.draw do |map| | |||
|
125 | 125 | |
|
126 | 126 | end |
|
127 | 127 | |
|
128 | # Destroy uses a get request to prompt the user before the actual DELETE request | |
|
129 | map.project_destroy_confirm 'projects/:id/destroy', :controller => 'projects', :action => 'destroy', :conditions => {:method => :get} | |
|
130 | ||
|
131 | 128 | # TODO: port to be part of the resources route(s) |
|
132 | 129 | map.with_options :controller => 'projects' do |project_mapper| |
|
133 | 130 | project_mapper.with_options :conditions => {:method => :get} do |project_views| |
@@ -410,17 +410,17 class ProjectsControllerTest < ActionController::TestCase | |||
|
410 | 410 | assert_response :method_not_allowed |
|
411 | 411 | end |
|
412 | 412 | |
|
413 | def test_get_destroy | |
|
413 | def test_destroy_without_confirmation | |
|
414 | 414 | @request.session[:user_id] = 1 # admin |
|
415 |
|
|
|
415 | delete :destroy, :id => 1 | |
|
416 | 416 | assert_response :success |
|
417 | 417 | assert_template 'destroy' |
|
418 | 418 | assert_not_nil Project.find_by_id(1) |
|
419 | 419 | end |
|
420 | 420 | |
|
421 |
def test_ |
|
|
421 | def test_destroy | |
|
422 | 422 | @request.session[:user_id] = 1 # admin |
|
423 |
|
|
|
423 | delete :destroy, :id => 1, :confirm => 1 | |
|
424 | 424 | assert_redirected_to '/admin/projects' |
|
425 | 425 | assert_nil Project.find_by_id(1) |
|
426 | 426 | end |
General Comments 0
You need to be logged in to leave comments.
Login now