Project

General

Profile

Feature #34714 » 34714-v2.patch

Mizuki ISHIKAWA, 2021-02-22 01:48

View differences:

app/helpers/journals_helper.rb
28 28
  # Returns the action links for an issue journal
29 29
  def render_journal_actions(issue, journal, options={})
30 30
    links = []
31
    dropbown_links = []
31 32
    if journal.notes.present?
32 33
      if options[:reply_links]
33 34
        indice = journal.indice || @journal.issue.visible_journals_with_index.find{|j| j.id == @journal.id}.indice
......
40 41
                        )
41 42
      end
42 43
      if journal.editable_by?(User.current)
43
        links << link_to(l(:button_edit),
44
        dropbown_links << link_to(l(:button_edit),
44 45
                         edit_journal_path(journal),
45 46
                         :remote => true,
46 47
                         :method => 'get',
47
                         :title => l(:button_edit),
48
                         :class => 'icon-only icon-edit'
48
                         :class => 'icon icon-edit'
49 49
                        )
50
        links << link_to(l(:button_delete),
50
        dropbown_links << link_to(l(:button_delete),
51 51
                         journal_path(journal, :journal => {:notes => ""}),
52 52
                         :remote => true,
53 53
                         :method => 'put', :data => {:confirm => l(:text_are_you_sure)},
54
                         :title => l(:button_delete),
55
                         :class => 'icon-only icon-del'
54
                         :class => 'icon icon-del'
56 55
                        )
57 56
      end
58 57
    end
59
    safe_join(links, ' ')
58
    safe_join(links, ' ') +
59
    actions_dropdown do
60
      safe_join(dropbown_links, ' ')
61
    end
60 62
  end
61 63

  
62 64
  def render_notes(issue, journal, options={})
app/views/issues/_action_menu.html.erb
5 5
<%= link_to l(:button_log_time), new_issue_time_entry_path(@issue),
6 6
            :class => 'icon icon-time-add' if User.current.allowed_to?(:log_time, @project) %>
7 7
<%= watcher_link(@issue, User.current) %>
8
<%= link_to l(:button_copy), project_copy_issue_path(@project, @issue),
9
            :class => 'icon icon-copy' if User.current.allowed_to?(:copy_issues, @project) && Issue.allowed_target_projects.any? %>
10
<%= link_to l(:button_delete), issue_path(@issue),
11
            :data => {:confirm => issues_destroy_confirmation_message(@issue)},
12
            :method => :delete, :class => 'icon icon-del' if @issue.deletable? %>
8
<%= actions_dropdown do %>
9
  <%= link_to l(:button_copy), project_copy_issue_path(@project, @issue),
10
              :class => 'icon icon-copy' if User.current.allowed_to?(:copy_issues, @project) && Issue.allowed_target_projects.any? %>
11
  <%= link_to l(:button_delete), issue_path(@issue),
12
              :data => {:confirm => issues_destroy_confirmation_message(@issue)},
13
              :method => :delete, :class => 'icon icon-del' if @issue.deletable? %>
14
<% end %>
13 15
</div>
test/functional/issues_controller_test.rb
2072 2072
    get(:show, :params => {:id => 1})
2073 2073
    assert_response :success
2074 2074
    assert_select 'div.issue div.description', :text => /Unable to print recipes/
2075
    assert_select '.contextual' do
2076
      assert_select 'a', {:count => 2, :text => /Edit/}
2077
      assert_select 'a', {:count => 0, :text => /Log time/}
2078
      assert_select 'a', {:count => 0, :text => /Watch/}
2079
      assert_select 'div.drdn-items a', {:count => 0, :text => /Copy/}
2080
      assert_select 'div.drdn-items a', {:count => 0, :text => /Delete/}
2081
    end
2075 2082
    # anonymous role is allowed to add a note
2076 2083
    assert_select 'form#issue-form' do
2077 2084
      assert_select 'fieldset' do
......
2086 2093
    @request.session[:user_id] = 2
2087 2094
    get(:show, :params => {:id => 1})
2088 2095
    assert_select 'a', :text => /Quote/
2096
    assert_select '.contextual' do
2097
      assert_select 'a', {:count => 2, :text => /Edit/}
2098
      assert_select 'a', :text => /Log time/
2099
      assert_select 'a', :text => /Watch/
2100
      assert_select 'div.drdn-items a', :text => /Copy/
2101
      assert_select 'div.drdn-items a', :text => /Delete/
2102
    end
2089 2103
    assert_select 'form#issue-form' do
2090 2104
      assert_select 'fieldset' do
2091 2105
        assert_select 'legend', :text => 'Change properties'
test/helpers/journals_helper_test.rb
22 22
class JournalsHelperTest < Redmine::HelperTest
23 23
  include JournalsHelper
24 24

  
25
  fixtures :projects, :trackers, :issue_statuses, :issues,
25
  fixtures :projects, :trackers, :issue_statuses, :issues, :journals,
26 26
           :enumerations, :issue_categories,
27 27
           :projects_trackers,
28 28
           :users, :roles, :member_roles, :members,
......
49 49
    assert_kind_of Attachment, thumbnails.first
50 50
    assert_equal 'image.png', thumbnails.first.filename
51 51
  end
52

  
53
  def test_render_journal_actions_should_return_edit_link_and_actions_dropdown
54
    User.current = User.find(1)
55
    issue = Issue.find(1)
56
    journals = issue.visible_journals_with_index # add indice
57
    journal_actions = render_journal_actions(issue, journals.first, {reply_links: true})
58

  
59
    assert_select_in journal_actions, 'a[title=?][class="icon-only icon-comment"]', 'Quote'
60
    assert_select_in journal_actions, 'div[class="drdn-items"] a[class="icon icon-del"]'
61
    assert_select_in journal_actions, 'div[class="drdn-items"] a[class="icon icon-edit"]'
62
  end
52 63
end
(5-5/11)