summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-01-13 19:38:06 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-01-13 19:38:06 +0000
commit980b6db5c0227a9376392962e706aecf3fc1c066 (patch)
tree0359c6a6c716f2e549abd6baa950b14ffc80e0bc /test
parent919d0a68c39b14ac8970ad889e6dc9345fade7f0 (diff)
downloadredmine-980b6db5c0227a9376392962e706aecf3fc1c066.tar.gz
redmine-980b6db5c0227a9376392962e706aecf3fc1c066.zip
Adds "me" to user custom fields filters (#9923).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8638 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/unit/query_test.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb
index d958fd131..c3bc10544 100644
--- a/test/unit/query_test.rb
+++ b/test/unit/query_test.rb
@@ -413,6 +413,23 @@ class QueryTest < ActiveSupport::TestCase
assert !result.include?(i3)
end
+ def test_user_custom_field_filtered_on_me
+ User.current = User.find(2)
+ cf = IssueCustomField.create!(:field_format => 'user', :is_for_all => true, :is_filter => true, :name => 'User custom field', :tracker_ids => [1])
+ issue1 = Issue.create!(:project_id => 1, :tracker_id => 1, :custom_field_values => {cf.id.to_s => '2'}, :subject => 'Test', :author_id => 1)
+ issue2 = Issue.generate!(:project_id => 1, :tracker_id => 1, :custom_field_values => {cf.id.to_s => '3'})
+
+ query = Query.new(:name => '_', :project => Project.find(1))
+ filter = query.available_filters["cf_#{cf.id}"]
+ assert_not_nil filter
+ assert_include 'me', filter[:values].map{|v| v[1]}
+
+ query.filters = { "cf_#{cf.id}" => {:operator => '=', :values => ['me']}}
+ result = query.issues
+ assert_equal 1, result.size
+ assert issue1, result.first
+ end
+
def test_filter_my_projects
User.current = User.find(2)
query = Query.new(:name => '_')