Project

General

Profile

Feature #44021 » 0001-Add-last-note-author-to-assignee-dropdown-participan.patch

Go MAEDA, 2026-05-04 08:18

View differences:

app/helpers/application_helper.rb
involved_principals = []
# This optgroup is displayed only when editing a single issue
if @issue.present? && !@issue.new_record?
last_notes_author =
@issue.journals.visible(User.current).
where.not(:notes => '').
reorder(:id => :desc).
first&.user
involved_principals =
[@issue.author, @issue.prior_assigned_to].uniq.compact.map do |principal|
[
@issue.author,
@issue.prior_assigned_to,
last_notes_author
].uniq.compact.map do |principal|
[principal, {:disabled => !collection.include?(principal)}]
end
end
config/locales/en.yml
label_default_query: Default query
label_edited: Edited
label_time_by_author: "%{time} by %{author}"
label_involved_principals: Author / Previous assignee
label_involved_principals: Author / Recent participants
label_assignee_dropdown_display_format_users_then_groups: Users then groups
label_assignee_dropdown_display_format_groups_then_users: Groups then users
label_assignee_dropdown_display_format_users_by_group: Users by group
test/helpers/application_helper_test.rb
principals_options_for_select(users)
end
def test_principals_options_for_select_should_include_author_and_previous_assignee
def test_principals_options_for_select_should_include_author_previous_assignee_and_last_notes_author
set_language_if_valid 'en'
users = [User.find(2), User.find(3), User.find(1)]
users = [User.find(2), User.find(3), User.find(1), User.find(4)]
@issue = Issue.generate!(author_id: 1, assigned_to_id: 2)
@issue.init_journal(users.first, 'update')
@issue.assigned_to_id = 3
@issue.save
Journal.create!(:journalized => @issue, :user_id => 4, :notes => 'Last notes')
result = principals_options_for_select(users)
assert_select_in result, 'optgroup[label="Author / Previous assignee"]' do
assert_select_in result, 'optgroup[label="Author / Recent participants"]' do
assert_select 'option:nth-of-type(1)', text: 'Redmine Admin' # Author
assert_select 'option:nth-of-type(2)', text: 'John Smith' # Prior assignee
assert_select 'option:nth-of-type(3)', text: 'Robert Hill' # Last notes author
end
end
def test_principals_options_for_select_should_not_include_private_last_notes_author_without_permission
set_language_if_valid 'en'
User.current = User.find(3)
users = [User.find(2), User.find(3), User.find(1), User.find(4)]
@issue = Issue.generate!(author_id: 1, assigned_to_id: 2)
@issue.init_journal(users.first, 'update')
@issue.assigned_to_id = 3
@issue.save
Journal.create!(:journalized => @issue, :user_id => 4, :notes => 'Public notes')
Journal.create!(:journalized => @issue, :user_id => 8, :notes => 'Private notes', :private_notes => true)
result = principals_options_for_select(users)
assert_select_in result, 'optgroup[label="Author / Recent participants"]' do
assert_select 'option:nth-of-type(1)', text: 'Redmine Admin'
assert_select 'option:nth-of-type(2)', text: 'John Smith'
assert_select 'option:nth-of-type(3)', text: 'Robert Hill'
end
ensure
User.current = nil
end
def test_stylesheet_link_tag_should_pick_the_default_stylesheet
assert_match 'href="/assets/styles.css"', stylesheet_link_tag("styles")
end
(2-2/3)