]> source.dussan.org Git - redmine.git/commitdiff
Added ability to delete issues from different projects through contextual menu (...
authorJean-Baptiste Barth <jeanbaptiste.barth@gmail.com>
Thu, 7 Oct 2010 05:11:28 +0000 (05:11 +0000)
committerJean-Baptiste Barth <jeanbaptiste.barth@gmail.com>
Thu, 7 Oct 2010 05:11:28 +0000 (05:11 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4236 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/application_controller.rb
app/controllers/context_menus_controller.rb
app/controllers/issues_controller.rb
app/views/context_menus/issues.html.erb
test/functional/context_menus_controller_test.rb
test/functional/issues_controller_test.rb

index fd6fc52da0877afc08eace00f543ea64364fbe4c..1299dac36374dc8c6da42c6397044c5748283c03 100644 (file)
@@ -153,7 +153,7 @@ class ApplicationController < ActionController::Base
 
   # Authorize the user for the requested action
   def authorize(ctrl = params[:controller], action = params[:action], global = false)
-    allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project, :global => global)
+    allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project || @projects, :global => global)
     allowed ? true : deny_access
   end
 
index 5f4b02ca26761367f29dd638bee99f53e0771f5c..ae8517243d9024aadabffddc00fa17dd39d60fe4 100644 (file)
@@ -21,7 +21,7 @@ class ContextMenusController < ApplicationController
             :update => (@project && (User.current.allowed_to?(:edit_issues, @project) || (User.current.allowed_to?(:change_status, @project) && @allowed_statuses && !@allowed_statuses.empty?))),
             :move => (@project && User.current.allowed_to?(:move_issues, @project)),
             :copy => (@issue && @project.trackers.include?(@issue.tracker) && User.current.allowed_to?(:add_issues, @project)),
-            :delete => (@project && User.current.allowed_to?(:delete_issues, @project))
+            :delete => User.current.allowed_to?(:delete_issues, @projects)
             }
     if @project
       @assignables = @project.assignable_users
index d1378777a0334734a8a7ef13b556a03bff459c0d..2221db871e36ca8bf77814540f337b063f34dd05 100644 (file)
@@ -21,7 +21,7 @@ class IssuesController < ApplicationController
   
   before_filter :find_issue, :only => [:show, :edit, :update]
   before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :move, :perform_move, :destroy]
-  before_filter :check_project_uniqueness, :only => [:bulk_edit, :bulk_update, :move, :perform_move, :destroy]
+  before_filter :check_project_uniqueness, :only => [:bulk_edit, :bulk_update, :move, :perform_move]
   before_filter :find_project, :only => [:new, :create]
   before_filter :authorize, :except => [:index]
   before_filter :find_optional_project, :only => [:index]
@@ -242,7 +242,7 @@ class IssuesController < ApplicationController
     end
     @issues.each(&:destroy)
     respond_to do |format|
-      format.html { redirect_to :action => 'index', :project_id => @project }
+      format.html { redirect_back_or_default(:action => 'index', :project_id => @project) }
       format.xml  { head :ok }
       format.json  { head :ok }
     end
index 94d4e802f3fcc59f956edc47cda2090b5bcee297..3f45f4ea2047dc9d842132f82fb4ad24f2dec3f1 100644 (file)
                                :class => 'icon-copy', :disabled => !@can[:move]  %></li>
   <li><%= context_menu_link l(:button_move), new_issue_move_path(:ids => @issues.collect(&:id)),
                                :class => 'icon-move', :disabled => !@can[:move]  %></li>
-  <li><%= context_menu_link l(:button_delete), {:controller => 'issues', :action => 'destroy', :ids => @issues.collect(&:id)},
+  <li><%= context_menu_link l(:button_delete), {:controller => 'issues', :action => 'destroy', :ids => @issues.collect(&:id), :back_url => @back},
                             :method => :post, :confirm => l(:text_issues_destroy_confirmation), :class => 'icon-del', :disabled => !@can[:delete] %></li>
 
   <%= call_hook(:view_issues_context_menu_end, {:issues => @issues, :can => @can, :back => @back }) %>
index 0ebae695a9dd54561518a1d53eee08886d4c85bb..0202cf2c7ef2d83010cd630041fb6831a7540d0a 100644 (file)
@@ -79,14 +79,15 @@ class ContextMenusControllerTest < ActionController::TestCase
                                              :class => 'icon-del' }
   end
 
-  def test_context_menu_multiple_issues_of_different_project
+  def test_context_menu_multiple_issues_of_different_projects
     @request.session[:user_id] = 2
-    get :issues, :ids => [1, 2, 4]
+    get :issues, :ids => [1, 2, 6]
     assert_response :success
     assert_template 'context_menu'
+    ids = "ids%5B%5D=1&amp;ids%5B%5D=2&amp;ids%5B%5D=6"
     assert_tag :tag => 'a', :content => 'Delete',
-                            :attributes => { :href => '#',
-                                             :class => 'icon-del disabled' }
+                            :attributes => { :href => "/issues/destroy?#{ids}",
+                                             :class => 'icon-del' }
   end
   
 end
index 9e70233b25b8e87a7764a18bc0269fb25b0b1627..4db2dae865eac3b5756ffa0167ae09e0ab0b8d8f 100644 (file)
@@ -1061,6 +1061,13 @@ class IssuesControllerTest < ActionController::TestCase
     assert_equal 2, TimeEntry.find(2).issue_id
   end
   
+  def test_destroy_issues_from_different_projects
+    @request.session[:user_id] = 2
+    post :destroy, :ids => [1, 2, 6], :todo => 'destroy'
+    assert_redirected_to :controller => 'issues', :action => 'index'
+    assert !(Issue.find_by_id(1) || Issue.find_by_id(2) || Issue.find_by_id(6))
+  end
+  
   def test_default_search_scope
     get :index
     assert_tag :div, :attributes => {:id => 'quick-search'},