##// END OF EJS Templates
Added ability to delete issues from different projects through contextual menu (#5332)...
Jean-Baptiste Barth -
r4122:b255b7760ac6
parent child
Show More
@@ -153,7 +153,7 class ApplicationController < ActionController::Base
153 153
154 154 # Authorize the user for the requested action
155 155 def authorize(ctrl = params[:controller], action = params[:action], global = false)
156 allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project, :global => global)
156 allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project || @projects, :global => global)
157 157 allowed ? true : deny_access
158 158 end
159 159
@@ -21,7 +21,7 class ContextMenusController < ApplicationController
21 21 :update => (@project && (User.current.allowed_to?(:edit_issues, @project) || (User.current.allowed_to?(:change_status, @project) && @allowed_statuses && !@allowed_statuses.empty?))),
22 22 :move => (@project && User.current.allowed_to?(:move_issues, @project)),
23 23 :copy => (@issue && @project.trackers.include?(@issue.tracker) && User.current.allowed_to?(:add_issues, @project)),
24 :delete => (@project && User.current.allowed_to?(:delete_issues, @project))
24 :delete => User.current.allowed_to?(:delete_issues, @projects)
25 25 }
26 26 if @project
27 27 @assignables = @project.assignable_users
@@ -21,7 +21,7 class IssuesController < ApplicationController
21 21
22 22 before_filter :find_issue, :only => [:show, :edit, :update]
23 23 before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :move, :perform_move, :destroy]
24 before_filter :check_project_uniqueness, :only => [:bulk_edit, :bulk_update, :move, :perform_move, :destroy]
24 before_filter :check_project_uniqueness, :only => [:bulk_edit, :bulk_update, :move, :perform_move]
25 25 before_filter :find_project, :only => [:new, :create]
26 26 before_filter :authorize, :except => [:index]
27 27 before_filter :find_optional_project, :only => [:index]
@@ -242,7 +242,7 class IssuesController < ApplicationController
242 242 end
243 243 @issues.each(&:destroy)
244 244 respond_to do |format|
245 format.html { redirect_to :action => 'index', :project_id => @project }
245 format.html { redirect_back_or_default(:action => 'index', :project_id => @project) }
246 246 format.xml { head :ok }
247 247 format.json { head :ok }
248 248 end
@@ -115,7 +115,7
115 115 :class => 'icon-copy', :disabled => !@can[:move] %></li>
116 116 <li><%= context_menu_link l(:button_move), new_issue_move_path(:ids => @issues.collect(&:id)),
117 117 :class => 'icon-move', :disabled => !@can[:move] %></li>
118 <li><%= context_menu_link l(:button_delete), {:controller => 'issues', :action => 'destroy', :ids => @issues.collect(&:id)},
118 <li><%= context_menu_link l(:button_delete), {:controller => 'issues', :action => 'destroy', :ids => @issues.collect(&:id), :back_url => @back},
119 119 :method => :post, :confirm => l(:text_issues_destroy_confirmation), :class => 'icon-del', :disabled => !@can[:delete] %></li>
120 120
121 121 <%= call_hook(:view_issues_context_menu_end, {:issues => @issues, :can => @can, :back => @back }) %>
@@ -79,14 +79,15 class ContextMenusControllerTest < ActionController::TestCase
79 79 :class => 'icon-del' }
80 80 end
81 81
82 def test_context_menu_multiple_issues_of_different_project
82 def test_context_menu_multiple_issues_of_different_projects
83 83 @request.session[:user_id] = 2
84 get :issues, :ids => [1, 2, 4]
84 get :issues, :ids => [1, 2, 6]
85 85 assert_response :success
86 86 assert_template 'context_menu'
87 ids = "ids%5B%5D=1&amp;ids%5B%5D=2&amp;ids%5B%5D=6"
87 88 assert_tag :tag => 'a', :content => 'Delete',
88 :attributes => { :href => '#',
89 :class => 'icon-del disabled' }
89 :attributes => { :href => "/issues/destroy?#{ids}",
90 :class => 'icon-del' }
90 91 end
91 92
92 93 end
@@ -1061,6 +1061,13 class IssuesControllerTest < ActionController::TestCase
1061 1061 assert_equal 2, TimeEntry.find(2).issue_id
1062 1062 end
1063 1063
1064 def test_destroy_issues_from_different_projects
1065 @request.session[:user_id] = 2
1066 post :destroy, :ids => [1, 2, 6], :todo => 'destroy'
1067 assert_redirected_to :controller => 'issues', :action => 'index'
1068 assert !(Issue.find_by_id(1) || Issue.find_by_id(2) || Issue.find_by_id(6))
1069 end
1070
1064 1071 def test_default_search_scope
1065 1072 get :index
1066 1073 assert_tag :div, :attributes => {:id => 'quick-search'},
General Comments 0
You need to be logged in to leave comments. Login now