Feature #34714 » 34714.patch
| 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 = [] |
|
| 32 |
indice = journal.indice || @journal.issue.visible_journals_with_index.find{|j| j.id == @journal.id}.indice
|
|
| 33 | ||
| 31 | 34 |
if journal.notes.present? |
| 32 | 35 |
if options[:reply_links] |
| 33 |
indice = journal.indice || @journal.issue.visible_journals_with_index.find{|j| j.id == @journal.id}.indice
|
|
| 34 |
links << link_to(l(:button_quote), |
|
| 36 |
dropbown_links << link_to(l(:button_quote), |
|
| 35 | 37 |
quoted_issue_path(issue, :journal_id => journal, :journal_indice => indice), |
| 36 | 38 |
:remote => true, |
| 37 | 39 |
:method => 'post', |
| 38 |
:title => l(:button_quote), |
|
| 39 |
:class => 'icon-only icon-comment' |
|
| 40 |
:class => 'icon icon-comment' |
|
| 40 | 41 |
) |
| 41 | 42 |
end |
| 42 | 43 |
if journal.editable_by?(User.current) |
| ... | ... | |
| 47 | 48 |
:title => l(:button_edit), |
| 48 | 49 |
:class => 'icon-only icon-edit' |
| 49 | 50 |
) |
| 50 |
links << link_to(l(:button_delete), |
|
| 51 |
dropbown_links << link_to(l(:button_delete),
|
|
| 51 | 52 |
journal_path(journal, :journal => {:notes => ""}),
|
| 52 | 53 |
:remote => true, |
| 53 | 54 |
:method => 'put', :data => {:confirm => l(:text_are_you_sure)},
|
| 54 |
:title => l(:button_delete), |
|
| 55 |
:class => 'icon-only icon-del' |
|
| 55 |
:class => 'icon icon-del' |
|
| 56 | 56 |
) |
| 57 | 57 |
end |
| 58 | 58 |
end |
| 59 |
safe_join(links, ' ') |
|
| 59 |
safe_join(links, ' ') + |
|
| 60 |
actions_dropdown do |
|
| 61 |
safe_join(dropbown_links, ' ') |
|
| 62 |
end |
|
| 60 | 63 |
end |
| 61 | 64 | |
| 62 | 65 |
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-edit"]', 'Edit' |
|
| 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-comment"]' |
|
| 62 |
end |
|
| 52 | 63 |
end |