Defect #33521 » 0001-Use-issue_path-when-only-one-issue-is-modified-from-.patch
app/helpers/routes_helper.rb | ||
---|---|---|
79 | 79 |
end |
80 | 80 |
end |
81 | 81 | |
82 |
# Returns the path to bulk update issues or to issue path |
|
83 |
# if only one issue is selected for bulk update |
|
84 |
def _bulk_update_issues_path(issue, *args) |
|
85 |
if issue |
|
86 |
issue_path(issue, *args) |
|
87 |
else |
|
88 |
bulk_update_issues_path(*args) |
|
89 |
end |
|
90 |
end |
|
91 | ||
82 | 92 |
def board_path(board, *args) |
83 | 93 |
project_board_path(board.project, board, *args) |
84 | 94 |
end |
app/views/context_menus/issues.html.erb | ||
---|---|---|
14 | 14 |
<a href="#" class="submenu"><%= l(:field_status) %></a> |
15 | 15 |
<ul> |
16 | 16 |
<% @allowed_statuses.each do |s| -%> |
17 |
<li><%= context_menu_link s.name, bulk_update_issues_path(:ids => @issue_ids, :issue => {:status_id => s}, :back_url => @back), :method => :post,
|
|
17 |
<li><%= context_menu_link s.name, _bulk_update_issues_path(@issue, :ids => @issue_ids, :issue => {:status_id => s}, :back_url => @back), :method => :patch,
|
|
18 | 18 |
:selected => (@issue && s == @issue.status), :disabled => !@can[:edit] %></li> |
19 | 19 |
<% end -%> |
20 | 20 |
</ul> |
... | ... | |
26 | 26 |
<a href="#" class="submenu"><%= l(:field_tracker) %></a> |
27 | 27 |
<ul> |
28 | 28 |
<% @trackers.each do |t| -%> |
29 |
<li><%= context_menu_link t.name, bulk_update_issues_path(:ids => @issue_ids, :issue => {'tracker_id' => t}, :back_url => @back), :method => :post,
|
|
29 |
<li><%= context_menu_link t.name, _bulk_update_issues_path(@issue, :ids => @issue_ids, :issue => {'tracker_id' => t}, :back_url => @back), :method => :patch,
|
|
30 | 30 |
:selected => (@issue && t == @issue.tracker), :disabled => !@can[:edit] %></li> |
31 | 31 |
<% end -%> |
32 | 32 |
</ul> |
... | ... | |
38 | 38 |
<a href="#" class="submenu"><%= l(:field_priority) %></a> |
39 | 39 |
<ul> |
40 | 40 |
<% @priorities.each do |p| -%> |
41 |
<li><%= context_menu_link p.name, bulk_update_issues_path(:ids => @issue_ids, :issue => {'priority_id' => p}, :back_url => @back), :method => :post,
|
|
41 |
<li><%= context_menu_link p.name, _bulk_update_issues_path(@issue, :ids => @issue_ids, :issue => {'priority_id' => p}, :back_url => @back), :method => :patch,
|
|
42 | 42 |
:selected => (@issue && p == @issue.priority), :disabled => (!@can[:edit] || @issues.any?(&:priority_derived?)) %></li> |
43 | 43 |
<% end -%> |
44 | 44 |
</ul> |
... | ... | |
50 | 50 |
<a href="#" class="submenu"><%= l(:field_fixed_version) %></a> |
51 | 51 |
<ul> |
52 | 52 |
<% @versions.sort.each do |v| -%> |
53 |
<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,
|
|
53 |
<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,
|
|
54 | 54 |
:selected => (@issue && v == @issue.fixed_version), :disabled => !@can[:edit] %></li> |
55 | 55 |
<% end -%> |
56 |
<li><%= context_menu_link l(:label_none), bulk_update_issues_path(:ids => @issue_ids, :issue => {'fixed_version_id' => 'none'}, :back_url => @back), :method => :post,
|
|
56 |
<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,
|
|
57 | 57 |
:selected => (@issue && @issue.fixed_version.nil?), :disabled => !@can[:edit] %></li> |
58 | 58 |
</ul> |
59 | 59 |
</li> |
... | ... | |
64 | 64 |
<a href="#" class="submenu"><%= l(:field_assigned_to) %></a> |
65 | 65 |
<ul> |
66 | 66 |
<% if @assignables.include?(User.current) %> |
67 |
<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,
|
|
67 |
<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,
|
|
68 | 68 |
:disabled => !@can[:edit] %></li> |
69 | 69 |
<% end %> |
70 | 70 |
<% @assignables.each do |u| -%> |
71 |
<li><%= context_menu_link u.name, bulk_update_issues_path(:ids => @issue_ids, :issue => {'assigned_to_id' => u}, :back_url => @back), :method => :post,
|
|
71 |
<li><%= context_menu_link u.name, _bulk_update_issues_path(@issue, :ids => @issue_ids, :issue => {'assigned_to_id' => u}, :back_url => @back), :method => :patch,
|
|
72 | 72 |
:selected => (@issue && u == @issue.assigned_to), :disabled => !@can[:edit] %></li> |
73 | 73 |
<% end -%> |
74 |
<li><%= context_menu_link l(:label_nobody), bulk_update_issues_path(:ids => @issue_ids, :issue => {'assigned_to_id' => 'none'}, :back_url => @back), :method => :post,
|
|
74 |
<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,
|
|
75 | 75 |
:selected => (@issue && @issue.assigned_to.nil?), :disabled => !@can[:edit] %></li> |
76 | 76 |
</ul> |
77 | 77 |
</li> |
... | ... | |
82 | 82 |
<a href="#" class="submenu"><%= l(:field_category) %></a> |
83 | 83 |
<ul> |
84 | 84 |
<% @project.issue_categories.each do |u| -%> |
85 |
<li><%= context_menu_link u.name, bulk_update_issues_path(:ids => @issue_ids, :issue => {'category_id' => u}, :back_url => @back), :method => :post,
|
|
85 |
<li><%= context_menu_link u.name, _bulk_update_issues_path(@issue, :ids => @issue_ids, :issue => {'category_id' => u}, :back_url => @back), :method => :patch,
|
|
86 | 86 |
:selected => (@issue && u == @issue.category), :disabled => !@can[:edit] %></li> |
87 | 87 |
<% end -%> |
88 |
<li><%= context_menu_link l(:label_none), bulk_update_issues_path(:ids => @issue_ids, :issue => {'category_id' => 'none'}, :back_url => @back), :method => :post,
|
|
88 |
<li><%= context_menu_link l(:label_none), _bulk_update_issues_path(@issue, :ids => @issue_ids, :issue => {'category_id' => 'none'}, :back_url => @back), :method => :patch,
|
|
89 | 89 |
:selected => (@issue && @issue.category.nil?), :disabled => !@can[:edit] %></li> |
90 | 90 |
</ul> |
91 | 91 |
</li> |
... | ... | |
96 | 96 |
<a href="#" class="submenu"><%= l(:field_done_ratio) %></a> |
97 | 97 |
<ul> |
98 | 98 |
<% (0..10).map{|x|x*10}.each do |p| -%> |
99 |
<li><%= context_menu_link "#{p}%", bulk_update_issues_path(:ids => @issue_ids, :issue => {'done_ratio' => p}, :back_url => @back), :method => :post,
|
|
99 |
<li><%= context_menu_link "#{p}%", _bulk_update_issues_path(@issue, :ids => @issue_ids, :issue => {'done_ratio' => p}, :back_url => @back), :method => :patch,
|
|
100 | 100 |
:selected => (@issue && p == @issue.done_ratio), :disabled => (!@can[:edit] || @issues.any?(&:done_ratio_derived?)) %></li> |
101 | 101 |
<% end -%> |
102 | 102 |
</ul> |
config/routes.rb | ||
---|---|---|
192 | 192 |
end |
193 | 193 |
collection do |
194 | 194 |
match 'bulk_edit', :via => [:get, :post] |
195 |
post 'bulk_update'
|
|
195 |
match 'bulk_update', :via => [:post, :patch]
|
|
196 | 196 |
end |
197 | 197 |
resources :time_entries, :controller => 'timelog', :only => [:new, :create] |
198 | 198 |
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 :issues, :params => { |
42 | 42 |
:ids => [1] |
... | ... | |
48 | 48 |
assert_select 'a.icon-del[href=?]', '/issues?ids%5B%5D=1', :text => 'Delete' |
49 | 49 | |
50 | 50 |
# Statuses |
51 |
assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bstatus_id%5D=5', :text => 'Closed'
|
|
52 |
assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bpriority_id%5D=8', :text => 'Immediate'
|
|
51 |
assert_select 'a[href=?]', '/issues/1?ids%5B%5D=1&issue%5Bstatus_id%5D=5', :text => 'Closed'
|
|
52 |
assert_select 'a[href=?]', '/issues/1?ids%5B%5D=1&issue%5Bpriority_id%5D=8', :text => 'Immediate'
|
|
53 | 53 |
# No inactive priorities |
54 | 54 |
assert_select 'a', :text => /Inactive Priority/, :count => 0 |
55 | 55 |
# Versions |
56 |
assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bfixed_version_id%5D=3', :text => '2.0'
|
|
57 |
assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bfixed_version_id%5D=4', :text => 'eCookbook Subproject 1 - 2.0'
|
|
56 |
assert_select 'a[href=?]', '/issues/1?ids%5B%5D=1&issue%5Bfixed_version_id%5D=3', :text => '2.0'
|
|
57 |
assert_select 'a[href=?]', '/issues/1?ids%5B%5D=1&issue%5Bfixed_version_id%5D=4', :text => 'eCookbook Subproject 1 - 2.0'
|
|
58 | 58 |
# Assignees |
59 |
assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bassigned_to_id%5D=3', :text => 'Dave Lopper' |
|
59 |
assert_select 'a[href=?]', '/issues/1?ids%5B%5D=1&issue%5Bassigned_to_id%5D=3', :text => 'Dave Lopper' |
|
60 |
end |
|
61 | ||
62 |
def test_context_menu_multiple_issues_should_link_to_bulk_update_issues_path |
|
63 |
@request.session[:user_id] = 2 |
|
64 |
get :issues, :params => { |
|
65 |
:ids => [1, 2] |
|
66 |
} |
|
67 |
assert_response :success |
|
68 | ||
69 |
assert_select 'a.icon-edit[href=?]', '/issues/bulk_edit?ids%5B%5D=1&ids%5B%5D=2', :text => 'Edit' |
|
70 |
assert_select 'a.icon-copy[href=?]', '/issues/bulk_edit?copy=1&ids%5B%5D=1&ids%5B%5D=2', :text => 'Copy' |
|
71 |
assert_select 'a.icon-del[href=?]', '/issues?ids%5B%5D=1&ids%5B%5D=2', :text => 'Delete' |
|
72 | ||
73 |
# Statuses |
|
74 |
assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&ids%5B%5D=2&issue%5Bstatus_id%5D=5', :text => 'Closed' |
|
75 |
assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&ids%5B%5D=2&issue%5Bpriority_id%5D=8', :text => 'Immediate' |
|
76 |
# No inactive priorities |
|
77 |
assert_select 'a', :text => /Inactive Priority/, :count => 0 |
|
78 |
# Versions |
|
79 |
assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&ids%5B%5D=2&issue%5Bfixed_version_id%5D=3', :text => '2.0' |
|
80 |
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' |
|
81 |
# Assignees |
|
82 |
assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&ids%5B%5D=2&issue%5Bassigned_to_id%5D=3', :text => 'Dave Lopper' |
|
60 | 83 |
end |
61 | 84 | |
62 | 85 |
def test_context_menu_one_issue_by_anonymous |
... | ... | |
231 | 254 |
def test_context_menu_by_assignable_user_should_include_assigned_to_me_link |
232 | 255 |
@request.session[:user_id] = 2 |
233 | 256 |
get :issues, :params => { |
234 |
:ids => [1] |
|
257 |
:ids => [1, 2]
|
|
235 | 258 |
} |
236 | 259 |
assert_response :success |
237 | 260 | |
238 |
assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bassigned_to_id%5D=2', :text => / me / |
|
261 |
assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&ids%5B%5D=2&issue%5Bassigned_to_id%5D=2', :text => / me /
|
|
239 | 262 |
end |
240 | 263 | |
241 | 264 |
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 |