mirror of
https://github.com/meineerde/redmine.git
synced 2025-10-17 17:01:01 +00:00
Add "<< me >>" option to user format issue custom fields (#31444).
Patch by Mizuki ISHIKAWA. git-svn-id: http://svn.redmine.org/redmine/trunk@18288 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
8e76585550
commit
28f37adcd3
@ -818,7 +818,10 @@ module Redmine
|
|||||||
field_attributes :user_role
|
field_attributes :user_role
|
||||||
|
|
||||||
def possible_values_options(custom_field, object=nil)
|
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
|
end
|
||||||
|
|
||||||
def possible_values_records(custom_field, object=nil)
|
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 "li.cf_#{field.id}" do
|
||||||
assert_select 'a[href="#"]', :text => 'User'
|
assert_select 'a[href="#"]', :text => 'User'
|
||||||
assert_select 'ul' do
|
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=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'
|
assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none'
|
||||||
end
|
end
|
||||||
|
|||||||
@ -2883,7 +2883,7 @@ class IssuesControllerTest < Redmine::ControllerTest
|
|||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'select[name=?][multiple=multiple]', "issue[custom_field_values][#{field.id}][]" do
|
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'
|
assert_select 'option[value="2"]', :text => 'John Smith'
|
||||||
end
|
end
|
||||||
assert_select 'input[name=?][type=hidden][value=?]', "issue[custom_field_values][#{field.id}][]", ''
|
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_response :success
|
||||||
|
|
||||||
assert_select 'select.user_cf[name=?]', "issue[custom_field_values][#{field.id}]" do
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -81,6 +81,14 @@ class Redmine::UserFieldFormatTest < ActionView::TestCase
|
|||||||
assert_equal ['Dave Lopper'], field.possible_values_options(project).map(&:first)
|
assert_equal ['Dave Lopper'], field.possible_values_options(project).map(&:first)
|
||||||
end
|
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
|
def test_value_from_keyword_should_return_user_id
|
||||||
field = IssueCustomField.new(:field_format => 'user')
|
field = IssueCustomField.new(:field_format => 'user')
|
||||||
project = Project.find(1)
|
project = Project.find(1)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user