Defect #33521 » 0001-Use-issue-path-instead-of-bulk-update-issues-path-wh.patch
app/helpers/routes_helper.rb | ||
---|---|---|
87 | 87 |
end |
88 | 88 |
end |
89 | 89 | |
90 |
# Returns the path to bulk update issues or to issue path |
|
91 |
# if only one issue is selected for bulk update |
|
92 |
def _bulk_update_issues_path(issue, *args) |
|
93 |
if issue |
|
94 |
issue_path(issue, *args) |
|
95 |
else |
|
96 |
bulk_update_issues_path(*args) |
|
97 |
end |
|
98 |
end |
|
99 | ||
90 | 100 |
def board_path(board, *args) |
91 | 101 |
project_board_path(board.project, board, *args) |
92 | 102 |
end |
app/views/context_menus/issues.html.erb | ||
---|---|---|
17 | 17 |
<li> |
18 | 18 |
<%= context_menu_link( |
19 | 19 |
s.name, |
20 |
bulk_update_issues_path( |
|
20 |
_bulk_update_issues_path( |
|
21 |
@issue, |
|
21 | 22 |
:ids => @issue_ids, :issue => {:status_id => s}, :back_url => @back |
22 | 23 |
), |
23 | 24 |
:method => :post, |
... | ... | |
34 | 35 |
<a href="#" class="submenu"><%= l(:field_tracker) %></a> |
35 | 36 |
<ul> |
36 | 37 |
<% @trackers.each do |t| -%> |
37 |
<li><%= context_menu_link t.name, bulk_update_issues_path(:ids => @issue_ids, :issue => {'tracker_id' => t}, :back_url => @back), :method => :post,
|
|
38 |
<li><%= context_menu_link t.name, _bulk_update_issues_path(@issue, :ids => @issue_ids, :issue => {'tracker_id' => t}, :back_url => @back), :method => :patch,
|
|
38 | 39 |
:selected => (@issue && t == @issue.tracker), :disabled => !@can[:edit] %></li> |
39 | 40 |
<% end -%> |
40 | 41 |
</ul> |
... | ... | |
46 | 47 |
<a href="#" class="submenu"><%= l(:field_priority) %></a> |
47 | 48 |
<ul> |
48 | 49 |
<% @priorities.each do |p| -%> |
49 |
<li><%= context_menu_link p.name, bulk_update_issues_path(:ids => @issue_ids, :issue => {'priority_id' => p}, :back_url => @back), :method => :post,
|
|
50 |
<li><%= context_menu_link p.name, _bulk_update_issues_path(@issue, :ids => @issue_ids, :issue => {'priority_id' => p}, :back_url => @back), :method => :patch,
|
|
50 | 51 |
:selected => (@issue && p == @issue.priority), :disabled => (!@can[:edit] || @issues.any?(&:priority_derived?)) %></li> |
51 | 52 |
<% end -%> |
52 | 53 |
</ul> |
... | ... | |
58 | 59 |
<a href="#" class="submenu"><%= l(:field_fixed_version) %></a> |
59 | 60 |
<ul> |
60 | 61 |
<% @versions.sort.each do |v| -%> |
61 |
<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,
|
|
62 |
<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,
|
|
62 | 63 |
:selected => (@issue && v == @issue.fixed_version), :disabled => !@can[:edit] %></li> |
63 | 64 |
<% end -%> |
64 |
<li><%= context_menu_link l(:label_none), bulk_update_issues_path(:ids => @issue_ids, :issue => {'fixed_version_id' => 'none'}, :back_url => @back), :method => :post,
|
|
65 |
<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,
|
|
65 | 66 |
:selected => (@issue && @issue.fixed_version.nil?), :disabled => !@can[:edit] %></li> |
66 | 67 |
</ul> |
67 | 68 |
</li> |
... | ... | |
72 | 73 |
<a href="#" class="submenu"><%= l(:field_assigned_to) %></a> |
73 | 74 |
<ul> |
74 | 75 |
<% if @assignables.include?(User.current) %> |
75 |
<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,
|
|
76 |
<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,
|
|
76 | 77 |
:disabled => !@can[:edit] %></li> |
77 | 78 |
<% end %> |
78 | 79 |
<% @assignables.each do |u| -%> |
79 |
<li><%= context_menu_link u.name, bulk_update_issues_path(:ids => @issue_ids, :issue => {'assigned_to_id' => u}, :back_url => @back), :method => :post,
|
|
80 |
<li><%= context_menu_link u.name, _bulk_update_issues_path(@issue, :ids => @issue_ids, :issue => {'assigned_to_id' => u}, :back_url => @back), :method => :patch,
|
|
80 | 81 |
:selected => (@issue && u == @issue.assigned_to), :disabled => !@can[:edit] %></li> |
81 | 82 |
<% end -%> |
82 |
<li><%= context_menu_link l(:label_nobody), bulk_update_issues_path(:ids => @issue_ids, :issue => {'assigned_to_id' => 'none'}, :back_url => @back), :method => :post,
|
|
83 |
<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,
|
|
83 | 84 |
:selected => (@issue && @issue.assigned_to.nil?), :disabled => !@can[:edit] %></li> |
84 | 85 |
</ul> |
85 | 86 |
</li> |
... | ... | |
90 | 91 |
<a href="#" class="submenu"><%= l(:field_category) %></a> |
91 | 92 |
<ul> |
92 | 93 |
<% @project.issue_categories.each do |u| -%> |
93 |
<li><%= context_menu_link u.name, bulk_update_issues_path(:ids => @issue_ids, :issue => {'category_id' => u}, :back_url => @back), :method => :post,
|
|
94 |
<li><%= context_menu_link u.name, _bulk_update_issues_path(@issue, :ids => @issue_ids, :issue => {'category_id' => u}, :back_url => @back), :method => :patch,
|
|
94 | 95 |
:selected => (@issue && u == @issue.category), :disabled => !@can[:edit] %></li> |
95 | 96 |
<% end -%> |
96 |
<li><%= context_menu_link l(:label_none), bulk_update_issues_path(:ids => @issue_ids, :issue => {'category_id' => 'none'}, :back_url => @back), :method => :post,
|
|
97 |
<li><%= context_menu_link l(:label_none), _bulk_update_issues_path(@issue, :ids => @issue_ids, :issue => {'category_id' => 'none'}, :back_url => @back), :method => :patch,
|
|
97 | 98 |
:selected => (@issue && @issue.category.nil?), :disabled => !@can[:edit] %></li> |
98 | 99 |
</ul> |
99 | 100 |
</li> |
... | ... | |
104 | 105 |
<a href="#" class="submenu"><%= l(:field_done_ratio) %></a> |
105 | 106 |
<ul> |
106 | 107 |
<% (0..10).map{|x|x*10}.each do |p| -%> |
107 |
<li><%= context_menu_link "#{p}%", bulk_update_issues_path(:ids => @issue_ids, :issue => {'done_ratio' => p}, :back_url => @back), :method => :post,
|
|
108 |
<li><%= context_menu_link "#{p}%", _bulk_update_issues_path(@issue, :ids => @issue_ids, :issue => {'done_ratio' => p}, :back_url => @back), :method => :patch,
|
|
108 | 109 |
:selected => (@issue && p == @issue.done_ratio), :disabled => (!@can[:edit] || @issues.any?(&:done_ratio_derived?)) %></li> |
109 | 110 |
<% end -%> |
110 | 111 |
</ul> |
config/routes.rb | ||
---|---|---|
215 | 215 |
end |
216 | 216 |
collection do |
217 | 217 |
match 'bulk_edit', :via => [:get, :post] |
218 |
post 'bulk_update'
|
|
218 |
match 'bulk_update', :via => [:post, :patch]
|
|
219 | 219 |
end |
220 | 220 |
resources :time_entries, :controller => 'timelog', :only => [:new, :create] |
221 | 221 |
shallow do |
test/functional/context_menus_controller_test.rb | ||
---|---|---|
36 | 36 |
:time_entries, |
37 | 37 |
:custom_fields, :custom_fields_trackers, :custom_fields_projects |
38 | 38 | |
39 |
def test_context_menu_one_issue |
|
39 |
def test_context_menu_one_issue_should_link_to_issue_path
|
|
40 | 40 |
@request.session[:user_id] = 2 |
41 | 41 |
get( |
42 | 42 |
:issues, |
... | ... | |
52 | 52 |
assert_select 'a.icon-del[href=?]', '/issues?ids%5B%5D=1', :text => 'Delete' |
53 | 53 | |
54 | 54 |
# Statuses |
55 |
assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bstatus_id%5D=5', :text => 'Closed'
|
|
56 |
assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bpriority_id%5D=8', :text => 'Immediate'
|
|
55 |
assert_select 'a[href=?]', '/issues/1?ids%5B%5D=1&issue%5Bstatus_id%5D=5', :text => 'Closed'
|
|
56 |
assert_select 'a[href=?]', '/issues/1?ids%5B%5D=1&issue%5Bpriority_id%5D=8', :text => 'Immediate'
|
|
57 | 57 |
# No inactive priorities |
58 | 58 |
assert_select 'a', :text => /Inactive Priority/, :count => 0 |
59 | 59 |
# Versions |
60 |
assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bfixed_version_id%5D=3', :text => '2.0'
|
|
61 |
assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bfixed_version_id%5D=4', :text => 'eCookbook Subproject 1 - 2.0'
|
|
60 |
assert_select 'a[href=?]', '/issues/1?ids%5B%5D=1&issue%5Bfixed_version_id%5D=3', :text => '2.0'
|
|
61 |
assert_select 'a[href=?]', '/issues/1?ids%5B%5D=1&issue%5Bfixed_version_id%5D=4', :text => 'eCookbook Subproject 1 - 2.0'
|
|
62 | 62 |
# Assignees |
63 |
assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bassigned_to_id%5D=3', :text => 'Dave Lopper' |
|
63 |
assert_select 'a[href=?]', '/issues/1?ids%5B%5D=1&issue%5Bassigned_to_id%5D=3', :text => 'Dave Lopper' |
|
64 |
end |
|
65 | ||
66 |
def test_context_menu_multiple_issues_should_link_to_bulk_update_issues_path |
|
67 |
@request.session[:user_id] = 2 |
|
68 |
get :issues, :params => { |
|
69 |
:ids => [1, 2] |
|
70 |
} |
|
71 |
assert_response :success |
|
72 | ||
73 |
assert_select 'a.icon-edit[href=?]', '/issues/bulk_edit?ids%5B%5D=1&ids%5B%5D=2', :text => 'Edit' |
|
74 |
assert_select 'a.icon-copy[href=?]', '/issues/bulk_edit?copy=1&ids%5B%5D=1&ids%5B%5D=2', :text => 'Copy' |
|
75 |
assert_select 'a.icon-del[href=?]', '/issues?ids%5B%5D=1&ids%5B%5D=2', :text => 'Delete' |
|
76 | ||
77 |
# Statuses |
|
78 |
assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&ids%5B%5D=2&issue%5Bstatus_id%5D=5', :text => 'Closed' |
|
79 |
assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&ids%5B%5D=2&issue%5Bpriority_id%5D=8', :text => 'Immediate' |
|
80 |
# No inactive priorities |
|
81 |
assert_select 'a', :text => /Inactive Priority/, :count => 0 |
|
82 |
# Versions |
|
83 |
assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&ids%5B%5D=2&issue%5Bfixed_version_id%5D=3', :text => '2.0' |
|
84 |
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' |
|
85 |
# Assignees |
|
86 |
assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&ids%5B%5D=2&issue%5Bassigned_to_id%5D=3', :text => 'Dave Lopper' |
|
64 | 87 |
end |
65 | 88 | |
66 | 89 |
def test_context_menu_one_issue_by_anonymous |
... | ... | |
272 | 295 |
get( |
273 | 296 |
:issues, |
274 | 297 |
:params => { |
275 |
:ids => [1] |
|
298 |
:ids => [1, 2]
|
|
276 | 299 |
} |
277 | 300 |
) |
278 | 301 |
assert_response :success |
279 | 302 | |
280 |
assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bassigned_to_id%5D=2', :text => / me / |
|
303 |
assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&ids%5B%5D=2&issue%5Bassigned_to_id%5D=2', :text => / me /
|
|
281 | 304 |
end |
282 | 305 | |
283 | 306 |
def test_context_menu_should_propose_shared_versions_for_issues_from_different_projects |
test/integration/routing/issues_test.rb | ||
---|---|---|
43 | 43 |
should_route 'GET /issues/bulk_edit' => 'issues#bulk_edit' |
44 | 44 |
should_route 'POST /issues/bulk_edit' => 'issues#bulk_edit' # For updating the bulk edit form |
45 | 45 |
should_route 'POST /issues/bulk_update' => 'issues#bulk_update' |
46 |
should_route 'PATCH /issues/bulk_update' => 'issues#bulk_update' |
|
46 | 47 |
end |
47 | 48 | |
48 | 49 |
def test_issues_scoped_under_project |