Commit 468b1ae1 authored by jplang's avatar jplang

Add "<< me >>" option to user format issue custom fields (#31444).

Patch by Mizuki ISHIKAWA.

git-svn-id: https://svn.redmine.org/redmine/trunk@18288 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent cb1ec38e
......@@ -818,7 +818,10 @@ module Redmine
field_attributes :user_role
def possible_values_options(custom_field, object=nil)
possible_values_records(custom_field, object).map {|u| [u.name, u.id.to_s]}
users = possible_values_records(custom_field, object)
options = users.map {|u| [u.name, u.id.to_s]}
options = [["<< #{l(:label_me)} >>", User.current.id]] + options if users.include?(User.current)
options
end
def possible_values_records(custom_field, object=nil)
......
......@@ -190,7 +190,7 @@ class ContextMenusControllerTest < Redmine::ControllerTest
assert_select "li.cf_#{field.id}" do
assert_select 'a[href="#"]', :text => 'User'
assert_select 'ul' do
assert_select 'a', Project.find(1).members.count + 1
assert_select 'a', Project.find(1).members.count + 2 # users + 'none' + 'me'
assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=2", :text => 'John Smith'
assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none'
end
......
......@@ -2883,7 +2883,7 @@ class IssuesControllerTest < Redmine::ControllerTest
assert_response :success
assert_select 'select[name=?][multiple=multiple]', "issue[custom_field_values][#{field.id}][]" do
assert_select 'option', Project.find(1).users.count
assert_select 'option', Project.find(1).users.count + 1 # users + 'me'
assert_select 'option[value="2"]', :text => 'John Smith'
end
assert_select 'input[name=?][type=hidden][value=?]', "issue[custom_field_values][#{field.id}][]", ''
......@@ -5673,7 +5673,7 @@ class IssuesControllerTest < Redmine::ControllerTest
assert_response :success
assert_select 'select.user_cf[name=?]', "issue[custom_field_values][#{field.id}]" do
assert_select 'option', Project.find(1).users.count + 2 # "no change" + "none" options
assert_select 'option', Project.find(1).users.count + 3 # "no change" + "none" + "me" options
end
end
......
......@@ -81,6 +81,14 @@ class Redmine::UserFieldFormatTest < ActionView::TestCase
assert_equal ['Dave Lopper'], field.possible_values_options(project).map(&:first)
end
def test_possible_values_options_should_return_project_members_and_me_if_logged_in
User.current = User.find(2)
field = IssueCustomField.new(:field_format => 'user')
project = Project.find(1)
assert_equal ['<< me >>', 'Dave Lopper', 'John Smith'], field.possible_values_options(project).map(&:first)
end
def test_value_from_keyword_should_return_user_id
field = IssueCustomField.new(:field_format => 'user')
project = Project.find(1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment