add_copy_link_item_to_context_menu_v2.patch

Mizuki ISHIKAWA, 2021-03-19 06:30

Download (4.19 KB)

View differences:

app/helpers/routes_helper.rb
29 29
    end
30 30
  end
31 31

  
32
  def _project_issues_url(project, *args)
33
    if project
34
      project_issues_url(project, *args)
35
    else
36
      issues_url(*args)
37
    end
38
  end
39

  
32 40
  def _project_news_path(project, *args)
33 41
    if project
34 42
      project_news_index_path(project, *args)
app/views/context_menus/issues.html.erb
155 155
  <li><%= context_menu_link l(:button_add_subtask), url_for_new_subtask(@issue),
156 156
          :class => 'icon icon-add' %></li>
157 157
  <% end %>
158
  <li><%= copy_object_url_link(issue_url(@issue)) %></li>
158 159
  <li><%= context_menu_link l(:button_copy), project_copy_issue_path(@project, @issue),
159 160
          :class => 'icon icon-copy', :disabled => !@can[:copy] %></li>
160 161
<% else %>
162
  <li><%= copy_object_url_link(_project_issues_url(@project, set_filter: 1, status_id: '*', issue_id: @issue_ids.join(','))) %></li>
161 163
  <li><%= context_menu_link l(:button_copy), bulk_edit_issues_path(:ids => @issue_ids, :copy => '1'),
162 164
                          :class => 'icon icon-copy', :disabled => !@can[:copy] %></li>
163 165
<% end %>
test/functional/context_menus_controller_test.rb
47 47
    assert_response :success
48 48

  
49 49
    assert_select 'a.icon-edit[href=?]', '/issues/1/edit', :text => 'Edit'
50
    assert_select 'a.icon-copy-link[data-clipboard-text=?]', 'http://test.host/issues/1', :text => 'Copy link'
50 51
    assert_select 'a.icon-copy[href=?]', '/projects/ecookbook/issues/1/copy', :text => 'Copy'
51 52
    assert_select 'a.icon-del[href=?]', '/issues?ids%5B%5D=1', :text => 'Delete'
52 53

  
......
89 90
    ids = [1, 2].map {|i| "ids%5B%5D=#{i}"}.join('&')
90 91

  
91 92
    assert_select 'a.icon-edit[href=?]', "/issues/bulk_edit?#{ids}", :text => 'Edit'
93
    # issue_id: '1,2', set_filter: 1, status_id: '*'
94
    assert_select 'a.icon-copy-link[data-clipboard-text=?]', "http://test.host/projects/ecookbook/issues?issue_id=1%2C2&set_filter=1&status_id=%2A", :text => 'Copy link'
92 95
    assert_select 'a.icon-copy[href=?]', "/issues/bulk_edit?copy=1&#{ids}", :text => 'Copy'
93 96
    assert_select 'a.icon-del[href=?]', "/issues?#{ids}", :text => 'Delete'
94 97

  
......
110 113
    ids = [1, 2, 6].map {|i| "ids%5B%5D=#{i}"}.join('&')
111 114

  
112 115
    assert_select 'a.icon-edit[href=?]', "/issues/bulk_edit?#{ids}", :text => 'Edit'
116
    # issue_id: '1,2,6', set_filter: 1, status_id: '*'
117
    assert_select 'a.icon-copy-link[data-clipboard-text=?]', "http://test.host/issues?issue_id=1%2C2%2C6&set_filter=1&status_id=%2A", :text => 'Copy link'
113 118
    assert_select 'a.icon-del[href=?]', "/issues?#{ids}", :text => 'Delete'
114 119

  
115 120
    assert_select 'a[href=?]', "/issues/bulk_update?#{ids}&issue%5Bstatus_id%5D=5", :text => 'Closed'
test/helpers/routes_helper_test.rb
40 40
    assert_equal '/issues/1/time_entries/new', _new_time_entry_path(nil, Issue.find(1))
41 41
    assert_equal '/time_entries/new', _new_time_entry_path(nil, nil)
42 42
  end
43

  
44
  def test_project_issues_url
45
    assert_equal 'http://test.host/projects/ecookbook/issues', _project_issues_url(Project.find(1))
46
    assert_equal 'http://test.host/issues', _project_issues_url(nil)
47
    assert_equal 'http://test.host/projects/ecookbook/issues?set_filter=1', _project_issues_url(Project.find(1), set_filter: 1)
48
    assert_equal 'http://test.host/issues?set_filter=1', _project_issues_url(nil, set_filter: 1)
49
  end
43 50
end