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
690 690
    involved_principals = []
691 691
    # This optgroup is displayed only when editing a single issue
692 692
    if @issue.present? && !@issue.new_record?
693
      last_notes_author =
694
        @issue.journals.visible(User.current).
695
          where.not(:notes => '').
696
          reorder(:id => :desc).
697
          first&.user
693 698
      involved_principals =
694
        [@issue.author, @issue.prior_assigned_to].uniq.compact.map do |principal|
699
        [
700
          @issue.author,
701
          @issue.prior_assigned_to,
702
          last_notes_author
703
        ].uniq.compact.map do |principal|
695 704
          [principal, {:disabled => !collection.include?(principal)}]
696 705
        end
697 706
    end
config/locales/en.yml
1172 1172
  label_default_query: Default query
1173 1173
  label_edited: Edited
1174 1174
  label_time_by_author: "%{time} by %{author}"
1175
  label_involved_principals: Author / Previous assignee
1175
  label_involved_principals: Author / Recent participants
1176 1176
  label_assignee_dropdown_display_format_users_then_groups: Users then groups
1177 1177
  label_assignee_dropdown_display_format_groups_then_users: Groups then users
1178 1178
  label_assignee_dropdown_display_format_users_by_group: Users by group
test/helpers/application_helper_test.rb
1993 1993
                   principals_options_for_select(users)
1994 1994
  end
1995 1995

  
1996
  def test_principals_options_for_select_should_include_author_and_previous_assignee
1996
  def test_principals_options_for_select_should_include_author_previous_assignee_and_last_notes_author
1997 1997
    set_language_if_valid 'en'
1998
    users = [User.find(2), User.find(3), User.find(1)]
1998
    users = [User.find(2), User.find(3), User.find(1), User.find(4)]
1999 1999
    @issue = Issue.generate!(author_id: 1, assigned_to_id: 2)
2000 2000
    @issue.init_journal(users.first, 'update')
2001 2001
    @issue.assigned_to_id = 3
2002 2002
    @issue.save
2003
    Journal.create!(:journalized => @issue, :user_id => 4, :notes => 'Last notes')
2003 2004

  
2004 2005
    result = principals_options_for_select(users)
2005
    assert_select_in result, 'optgroup[label="Author / Previous assignee"]' do
2006
    assert_select_in result, 'optgroup[label="Author / Recent participants"]' do
2006 2007
      assert_select 'option:nth-of-type(1)', text: 'Redmine Admin'  # Author
2007 2008
      assert_select 'option:nth-of-type(2)', text: 'John Smith'     # Prior assignee
2009
      assert_select 'option:nth-of-type(3)', text: 'Robert Hill'    # Last notes author
2008 2010
    end
2009 2011
  end
2010 2012

  
2013
  def test_principals_options_for_select_should_not_include_private_last_notes_author_without_permission
2014
    set_language_if_valid 'en'
2015
    User.current = User.find(3)
2016
    users = [User.find(2), User.find(3), User.find(1), User.find(4)]
2017
    @issue = Issue.generate!(author_id: 1, assigned_to_id: 2)
2018
    @issue.init_journal(users.first, 'update')
2019
    @issue.assigned_to_id = 3
2020
    @issue.save
2021
    Journal.create!(:journalized => @issue, :user_id => 4, :notes => 'Public notes')
2022
    Journal.create!(:journalized => @issue, :user_id => 8, :notes => 'Private notes', :private_notes => true)
2023

  
2024
    result = principals_options_for_select(users)
2025
    assert_select_in result, 'optgroup[label="Author / Recent participants"]' do
2026
      assert_select 'option:nth-of-type(1)', text: 'Redmine Admin'
2027
      assert_select 'option:nth-of-type(2)', text: 'John Smith'
2028
      assert_select 'option:nth-of-type(3)', text: 'Robert Hill'
2029
    end
2030
  ensure
2031
    User.current = nil
2032
  end
2033

  
2011 2034
  def test_stylesheet_link_tag_should_pick_the_default_stylesheet
2012 2035
    assert_match 'href="/assets/styles.css"', stylesheet_link_tag("styles")
2013 2036
  end
(2-2/3)