# Returns the action links for an issue journal
def render_journal_actions(issue, journal, options={})
links = []
+ dropbown_links = []
if journal.notes.present?
if options[:reply_links]
indice = journal.indice || @journal.issue.visible_journals_with_index.find{|j| j.id == @journal.id}.indice
:title => l(:button_edit),
:class => 'icon-only icon-edit'
)
- links << link_to(l(:button_delete),
- journal_path(journal, :journal => {:notes => ""}),
- :remote => true,
- :method => 'put', :data => {:confirm => l(:text_are_you_sure)},
- :title => l(:button_delete),
- :class => 'icon-only icon-del'
- )
+ dropbown_links << link_to(l(:button_delete),
+ journal_path(journal, :journal => {:notes => ""}),
+ :remote => true,
+ :method => 'put', :data => {:confirm => l(:text_are_you_sure)},
+ :class => 'icon icon-del'
+ )
end
end
- safe_join(links, ' ')
+ safe_join(links, ' ') + actions_dropdown {safe_join(dropbown_links, ' ')}
end
def render_notes(issue, journal, options={})
<%= link_to l(:button_log_time), new_issue_time_entry_path(@issue),
:class => 'icon icon-time-add' if User.current.allowed_to?(:log_time, @project) %>
<%= watcher_link(@issue, User.current) %>
-<%= link_to l(:button_copy), project_copy_issue_path(@project, @issue),
- :class => 'icon icon-copy' if User.current.allowed_to?(:copy_issues, @project) && Issue.allowed_target_projects.any? %>
-<%= link_to l(:button_delete), issue_path(@issue),
- :data => {:confirm => issues_destroy_confirmation_message(@issue)},
- :method => :delete, :class => 'icon icon-del' if @issue.deletable? %>
+<%= actions_dropdown do %>
+ <%= link_to l(:button_copy), project_copy_issue_path(@project, @issue),
+ :class => 'icon icon-copy' if User.current.allowed_to?(:copy_issues, @project) && Issue.allowed_target_projects.any? %>
+ <%= link_to l(:button_delete), issue_path(@issue),
+ :data => {:confirm => issues_destroy_confirmation_message(@issue)},
+ :method => :delete, :class => 'icon icon-del' if @issue.deletable? %>
+<% end %>
</div>
get(:show, :params => {:id => 1})
assert_response :success
assert_select 'div.issue div.description', :text => /Unable to print recipes/
+ assert_select '.contextual' do
+ assert_select 'a', {:count => 2, :text => /Edit/}
+ assert_select 'a', {:count => 0, :text => /Log time/}
+ assert_select 'a', {:count => 0, :text => /Watch/}
+ assert_select 'div.drdn-items a', {:count => 0, :text => /Copy/}
+ assert_select 'div.drdn-items a', {:count => 0, :text => /Delete/}
+ end
# anonymous role is allowed to add a note
assert_select 'form#issue-form' do
assert_select 'fieldset' do
@request.session[:user_id] = 2
get(:show, :params => {:id => 1})
assert_select 'a', :text => /Quote/
+ assert_select '.contextual' do
+ assert_select 'a', {:count => 2, :text => /Edit/}
+ assert_select 'a', :text => /Log time/
+ assert_select 'a', :text => /Watch/
+ assert_select 'div.drdn-items a', :text => /Copy/
+ assert_select 'div.drdn-items a', :text => /Delete/
+ end
assert_select 'form#issue-form' do
assert_select 'fieldset' do
assert_select 'legend', :text => 'Change properties'
class JournalsHelperTest < Redmine::HelperTest
include JournalsHelper
- fixtures :projects, :trackers, :issue_statuses, :issues,
+ fixtures :projects, :trackers, :issue_statuses, :issues, :journals,
:enumerations, :issue_categories,
:projects_trackers,
:users, :roles, :member_roles, :members,
assert_kind_of Attachment, thumbnails.first
assert_equal 'image.png', thumbnails.first.filename
end
+
+ def test_render_journal_actions_should_return_edit_link_and_actions_dropdown
+ User.current = User.find(1)
+ issue = Issue.find(1)
+ journals = issue.visible_journals_with_index # add indice
+ journal_actions = render_journal_actions(issue, journals.first, {reply_links: true})
+
+ assert_select_in journal_actions, 'a[title=?][class="icon-only icon-comment"]', 'Quote'
+ assert_select_in journal_actions, 'a[title=?][class="icon-only icon-edit"]', 'Edit'
+ assert_select_in journal_actions, 'div[class="drdn-items"] a[class="icon icon-del"]'
+ end
end