Defect #44376 » 0001-Cannot-deselect-current-user-in-multi-select-user-cu.patch
| lib/redmine/field_format.rb | ||
|---|---|---|
| 876 | 876 |
def possible_values_options(custom_field, object=nil) |
| 877 | 877 |
users = possible_values_records(custom_field, object) |
| 878 | 878 |
options = users.map {|u| [u.name, u.id.to_s]}
|
| 879 |
options = [["<< #{l(:label_me)} >>", User.current.id]] + options if users.include?(User.current)
|
|
| 879 |
if users.include?(User.current) |
|
| 880 |
if custom_field.multiple? |
|
| 881 |
options.delete([User.current.name, User.current.id.to_s]) |
|
| 882 |
options = [["#{User.current.name} << #{l(:label_me)} >>", User.current.id.to_s]] + options
|
|
| 883 |
else |
|
| 884 |
options = [["<< #{l(:label_me)} >>", User.current.id.to_s]] + options
|
|
| 885 |
end |
|
| 886 |
end |
|
| 880 | 887 |
options |
| 881 | 888 |
end |
| 882 | 889 | |
| test/unit/lib/redmine/field_format/user_field_format_test.rb | ||
|---|---|---|
| 84 | 84 |
assert_equal ['<< me >>', 'Dave Lopper', 'John Smith'], field.possible_values_options(project).map(&:first) |
| 85 | 85 |
end |
| 86 | 86 | |
| 87 |
def test_possible_values_options_for_multiple_custom_field_should_not_duplicate_current_user |
|
| 88 |
::I18n.locale = 'en' |
|
| 89 |
User.current = User.find(2) |
|
| 90 |
field = IssueCustomField.new(:field_format => 'user', :multiple => true) |
|
| 91 |
project = Project.find(1) |
|
| 92 | ||
| 93 |
options = field.possible_values_options(project) |
|
| 94 |
assert_equal ['John Smith << me >>', 'Dave Lopper'], options.map(&:first) |
|
| 95 |
assert_equal [User.current.id.to_s], options.filter_map {|label, value| value if label.include?('John Smith')}
|
|
| 96 |
end |
|
| 97 | ||
| 87 | 98 |
def test_value_from_keyword_should_return_user_id |
| 88 | 99 |
field = IssueCustomField.new(:field_format => 'user') |
| 89 | 100 |
project = Project.find(1) |
- « Previous
- 1
- 2
- Next »