Feature #31444 » feature-31444.patch
lib/redmine/field_format.rb | ||
---|---|---|
818 | 818 |
field_attributes :user_role |
819 | 819 | |
820 | 820 |
def possible_values_options(custom_field, object=nil) |
821 |
possible_values_records(custom_field, object).map {|u| [u.name, u.id.to_s]} |
|
821 |
users = possible_values_records(custom_field, object) |
|
822 |
options = users.map {|u| [u.name, u.id.to_s]} |
|
823 |
options = [["<< #{l(:label_me)} >>", User.current.id]] + options if users.include?(User.current) |
|
824 |
options |
|
822 | 825 |
end |
823 | 826 | |
824 | 827 |
def possible_values_records(custom_field, object=nil) |
test/functional/context_menus_controller_test.rb | ||
---|---|---|
190 | 190 |
assert_select "li.cf_#{field.id}" do |
191 | 191 |
assert_select 'a[href="#"]', :text => 'User' |
192 | 192 |
assert_select 'ul' do |
193 |
assert_select 'a', Project.find(1).members.count + 1
|
|
193 |
assert_select 'a', Project.find(1).members.count + 2 # users + 'none' + 'me'
|
|
194 | 194 |
assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=2", :text => 'John Smith' |
195 | 195 |
assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none' |
196 | 196 |
end |
test/functional/issues_controller_test.rb | ||
---|---|---|
2763 | 2763 |
assert_response :success |
2764 | 2764 | |
2765 | 2765 |
assert_select 'select[name=?][multiple=multiple]', "issue[custom_field_values][#{field.id}][]" do |
2766 |
assert_select 'option', Project.find(1).users.count |
|
2766 |
assert_select 'option', Project.find(1).users.count + 1 # users + 'me'
|
|
2767 | 2767 |
assert_select 'option[value="2"]', :text => 'John Smith' |
2768 | 2768 |
end |
2769 | 2769 |
assert_select 'input[name=?][type=hidden][value=?]', "issue[custom_field_values][#{field.id}][]", '' |
... | ... | |
5553 | 5553 |
assert_response :success |
5554 | 5554 | |
5555 | 5555 |
assert_select 'select.user_cf[name=?]', "issue[custom_field_values][#{field.id}]" do |
5556 |
assert_select 'option', Project.find(1).users.count + 2 # "no change" + "none" options
|
|
5556 |
assert_select 'option', Project.find(1).users.count + 3 # "no change" + "none" + "me" options
|
|
5557 | 5557 |
end |
5558 | 5558 |
end |
5559 | 5559 |
test/unit/lib/redmine/field_format/user_field_format_test.rb | ||
---|---|---|
81 | 81 |
assert_equal ['Dave Lopper'], field.possible_values_options(project).map(&:first) |
82 | 82 |
end |
83 | 83 | |
84 |
def test_possible_values_options_should_return_project_members_and_me_if_logged_in |
|
85 |
User.current = User.find(2) |
|
86 |
field = IssueCustomField.new(:field_format => 'user') |
|
87 |
project = Project.find(1) |
|
88 | ||
89 |
assert_equal ['<< me >>', 'Dave Lopper', 'John Smith'], field.possible_values_options(project).map(&:first) |
|
90 |
end |
|
91 | ||
84 | 92 |
def test_value_from_keyword_should_return_user_id |
85 | 93 |
field = IssueCustomField.new(:field_format => 'user') |
86 | 94 |
project = Project.find(1) |