diff options
-rw-r--r-- | app/helpers/routes_helper.rb | 10 | ||||
-rw-r--r-- | app/views/context_menus/issues.html.erb | 23 | ||||
-rw-r--r-- | config/routes.rb | 2 | ||||
-rw-r--r-- | test/functional/context_menus_controller_test.rb | 39 | ||||
-rw-r--r-- | test/integration/routing/issues_test.rb | 1 |
5 files changed, 55 insertions, 20 deletions
diff --git a/app/helpers/routes_helper.rb b/app/helpers/routes_helper.rb index 94c68c0a4..7c50bad1a 100644 --- a/app/helpers/routes_helper.rb +++ b/app/helpers/routes_helper.rb @@ -87,6 +87,16 @@ module RoutesHelper end end + # Returns the path to bulk update issues or to issue path + # if only one issue is selected for bulk update + def _bulk_update_issues_path(issue, *args) + if issue + issue_path(issue, *args) + else + bulk_update_issues_path(*args) + end + end + def board_path(board, *args) project_board_path(board.project, board, *args) end diff --git a/app/views/context_menus/issues.html.erb b/app/views/context_menus/issues.html.erb index cf402f120..9836b5dff 100644 --- a/app/views/context_menus/issues.html.erb +++ b/app/views/context_menus/issues.html.erb @@ -17,7 +17,8 @@ <li> <%= context_menu_link( s.name, - bulk_update_issues_path( + _bulk_update_issues_path( + @issue, :ids => @issue_ids, :issue => {:status_id => s}, :back_url => @back ), :method => :post, @@ -34,7 +35,7 @@ <a href="#" class="submenu"><%= l(:field_tracker) %></a> <ul> <% @trackers.each do |t| -%> - <li><%= context_menu_link t.name, bulk_update_issues_path(:ids => @issue_ids, :issue => {'tracker_id' => t}, :back_url => @back), :method => :post, + <li><%= context_menu_link t.name, _bulk_update_issues_path(@issue, :ids => @issue_ids, :issue => {'tracker_id' => t}, :back_url => @back), :method => :patch, :selected => (@issue && t == @issue.tracker), :disabled => !@can[:edit] %></li> <% end -%> </ul> @@ -46,7 +47,7 @@ <a href="#" class="submenu"><%= l(:field_priority) %></a> <ul> <% @priorities.each do |p| -%> - <li><%= context_menu_link p.name, bulk_update_issues_path(:ids => @issue_ids, :issue => {'priority_id' => p}, :back_url => @back), :method => :post, + <li><%= context_menu_link p.name, _bulk_update_issues_path(@issue, :ids => @issue_ids, :issue => {'priority_id' => p}, :back_url => @back), :method => :patch, :selected => (@issue && p == @issue.priority), :disabled => (!@can[:edit] || @issues.any?(&:priority_derived?)) %></li> <% end -%> </ul> @@ -58,10 +59,10 @@ <a href="#" class="submenu"><%= l(:field_fixed_version) %></a> <ul> <% @versions.sort.each do |v| -%> - <li><%= context_menu_link format_version_name(v), bulk_update_issues_path(:ids => @issue_ids, :issue => {'fixed_version_id' => v}, :back_url => @back), :method => :post, + <li><%= context_menu_link format_version_name(v), _bulk_update_issues_path(@issue, :ids => @issue_ids, :issue => {'fixed_version_id' => v}, :back_url => @back), :method => :patch, :selected => (@issue && v == @issue.fixed_version), :disabled => !@can[:edit] %></li> <% end -%> - <li><%= context_menu_link l(:label_none), bulk_update_issues_path(:ids => @issue_ids, :issue => {'fixed_version_id' => 'none'}, :back_url => @back), :method => :post, + <li><%= context_menu_link l(:label_none), _bulk_update_issues_path(@issue, :ids => @issue_ids, :issue => {'fixed_version_id' => 'none'}, :back_url => @back), :method => :patch, :selected => (@issue && @issue.fixed_version.nil?), :disabled => !@can[:edit] %></li> </ul> </li> @@ -72,14 +73,14 @@ <a href="#" class="submenu"><%= l(:field_assigned_to) %></a> <ul> <% if @assignables.include?(User.current) %> - <li><%= context_menu_link "<< #{l(:label_me)} >>", bulk_update_issues_path(:ids => @issue_ids, :issue => {'assigned_to_id' => User.current}, :back_url => @back), :method => :post, + <li><%= context_menu_link "<< #{l(:label_me)} >>", _bulk_update_issues_path(@issue, :ids => @issue_ids, :issue => {'assigned_to_id' => User.current}, :back_url => @back), :method => :patch, :disabled => !@can[:edit] %></li> <% end %> <% @assignables.each do |u| -%> - <li><%= context_menu_link u.name, bulk_update_issues_path(:ids => @issue_ids, :issue => {'assigned_to_id' => u}, :back_url => @back), :method => :post, + <li><%= context_menu_link u.name, _bulk_update_issues_path(@issue, :ids => @issue_ids, :issue => {'assigned_to_id' => u}, :back_url => @back), :method => :patch, :selected => (@issue && u == @issue.assigned_to), :disabled => !@can[:edit] %></li> <% end -%> - <li><%= context_menu_link l(:label_nobody), bulk_update_issues_path(:ids => @issue_ids, :issue => {'assigned_to_id' => 'none'}, :back_url => @back), :method => :post, + <li><%= context_menu_link l(:label_nobody), _bulk_update_issues_path(@issue, :ids => @issue_ids, :issue => {'assigned_to_id' => 'none'}, :back_url => @back), :method => :patch, :selected => (@issue && @issue.assigned_to.nil?), :disabled => !@can[:edit] %></li> </ul> </li> @@ -90,10 +91,10 @@ <a href="#" class="submenu"><%= l(:field_category) %></a> <ul> <% @project.issue_categories.each do |u| -%> - <li><%= context_menu_link u.name, bulk_update_issues_path(:ids => @issue_ids, :issue => {'category_id' => u}, :back_url => @back), :method => :post, + <li><%= context_menu_link u.name, _bulk_update_issues_path(@issue, :ids => @issue_ids, :issue => {'category_id' => u}, :back_url => @back), :method => :patch, :selected => (@issue && u == @issue.category), :disabled => !@can[:edit] %></li> <% end -%> - <li><%= context_menu_link l(:label_none), bulk_update_issues_path(:ids => @issue_ids, :issue => {'category_id' => 'none'}, :back_url => @back), :method => :post, + <li><%= context_menu_link l(:label_none), _bulk_update_issues_path(@issue, :ids => @issue_ids, :issue => {'category_id' => 'none'}, :back_url => @back), :method => :patch, :selected => (@issue && @issue.category.nil?), :disabled => !@can[:edit] %></li> </ul> </li> @@ -104,7 +105,7 @@ <a href="#" class="submenu"><%= l(:field_done_ratio) %></a> <ul> <% (0..10).map{|x|x*10}.each do |p| -%> - <li><%= context_menu_link "#{p}%", bulk_update_issues_path(:ids => @issue_ids, :issue => {'done_ratio' => p}, :back_url => @back), :method => :post, + <li><%= context_menu_link "#{p}%", _bulk_update_issues_path(@issue, :ids => @issue_ids, :issue => {'done_ratio' => p}, :back_url => @back), :method => :patch, :selected => (@issue && p == @issue.done_ratio), :disabled => (!@can[:edit] || @issues.any?(&:done_ratio_derived?)) %></li> <% end -%> </ul> diff --git a/config/routes.rb b/config/routes.rb index 1fd513d00..efb6db8e1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -215,7 +215,7 @@ Rails.application.routes.draw do end collection do match 'bulk_edit', :via => [:get, :post] - post 'bulk_update' + match 'bulk_update', :via => [:post, :patch] end resources :time_entries, :controller => 'timelog', :only => [:new, :create] shallow do diff --git a/test/functional/context_menus_controller_test.rb b/test/functional/context_menus_controller_test.rb index 5178ca61b..4b3b4aaca 100644 --- a/test/functional/context_menus_controller_test.rb +++ b/test/functional/context_menus_controller_test.rb @@ -36,7 +36,7 @@ class ContextMenusControllerTest < Redmine::ControllerTest :time_entries, :custom_fields, :custom_fields_trackers, :custom_fields_projects - def test_context_menu_one_issue + def test_context_menu_one_issue_should_link_to_issue_path @request.session[:user_id] = 2 get( :issues, @@ -52,15 +52,38 @@ class ContextMenusControllerTest < Redmine::ControllerTest assert_select 'a.icon-del[href=?]', '/issues?ids%5B%5D=1', :text => 'Delete' # Statuses - assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bstatus_id%5D=5', :text => 'Closed' - assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bpriority_id%5D=8', :text => 'Immediate' + assert_select 'a[href=?]', '/issues/1?ids%5B%5D=1&issue%5Bstatus_id%5D=5', :text => 'Closed' + assert_select 'a[href=?]', '/issues/1?ids%5B%5D=1&issue%5Bpriority_id%5D=8', :text => 'Immediate' # No inactive priorities assert_select 'a', :text => /Inactive Priority/, :count => 0 # Versions - assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bfixed_version_id%5D=3', :text => '2.0' - assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bfixed_version_id%5D=4', :text => 'eCookbook Subproject 1 - 2.0' + assert_select 'a[href=?]', '/issues/1?ids%5B%5D=1&issue%5Bfixed_version_id%5D=3', :text => '2.0' + assert_select 'a[href=?]', '/issues/1?ids%5B%5D=1&issue%5Bfixed_version_id%5D=4', :text => 'eCookbook Subproject 1 - 2.0' # Assignees - assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bassigned_to_id%5D=3', :text => 'Dave Lopper' + assert_select 'a[href=?]', '/issues/1?ids%5B%5D=1&issue%5Bassigned_to_id%5D=3', :text => 'Dave Lopper' + end + + def test_context_menu_multiple_issues_should_link_to_bulk_update_issues_path + @request.session[:user_id] = 2 + get :issues, :params => { + :ids => [1, 2] + } + assert_response :success + + assert_select 'a.icon-edit[href=?]', '/issues/bulk_edit?ids%5B%5D=1&ids%5B%5D=2', :text => 'Edit' + assert_select 'a.icon-copy[href=?]', '/issues/bulk_edit?copy=1&ids%5B%5D=1&ids%5B%5D=2', :text => 'Copy' + assert_select 'a.icon-del[href=?]', '/issues?ids%5B%5D=1&ids%5B%5D=2', :text => 'Delete' + + # Statuses + assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&ids%5B%5D=2&issue%5Bstatus_id%5D=5', :text => 'Closed' + assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&ids%5B%5D=2&issue%5Bpriority_id%5D=8', :text => 'Immediate' + # No inactive priorities + assert_select 'a', :text => /Inactive Priority/, :count => 0 + # Versions + assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&ids%5B%5D=2&issue%5Bfixed_version_id%5D=3', :text => '2.0' + assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&ids%5B%5D=2&issue%5Bfixed_version_id%5D=4', :text => 'eCookbook Subproject 1 - 2.0' + # Assignees + assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&ids%5B%5D=2&issue%5Bassigned_to_id%5D=3', :text => 'Dave Lopper' end def test_context_menu_one_issue_by_anonymous @@ -272,12 +295,12 @@ class ContextMenusControllerTest < Redmine::ControllerTest get( :issues, :params => { - :ids => [1] + :ids => [1, 2] } ) assert_response :success - assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bassigned_to_id%5D=2', :text => / me / + assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&ids%5B%5D=2&issue%5Bassigned_to_id%5D=2', :text => / me / end def test_context_menu_should_propose_shared_versions_for_issues_from_different_projects diff --git a/test/integration/routing/issues_test.rb b/test/integration/routing/issues_test.rb index 6ce58218b..33cc72d2c 100644 --- a/test/integration/routing/issues_test.rb +++ b/test/integration/routing/issues_test.rb @@ -43,6 +43,7 @@ class RoutingIssuesTest < Redmine::RoutingTest should_route 'GET /issues/bulk_edit' => 'issues#bulk_edit' should_route 'POST /issues/bulk_edit' => 'issues#bulk_edit' # For updating the bulk edit form should_route 'POST /issues/bulk_update' => 'issues#bulk_update' + should_route 'PATCH /issues/bulk_update' => 'issues#bulk_update' end def test_issues_scoped_under_project |