summaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/query_test.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb
index 8099df3f8..d20fefce4 100644
--- a/test/unit/query_test.rb
+++ b/test/unit/query_test.rb
@@ -939,6 +939,34 @@ class QueryTest < ActiveSupport::TestCase
assert_not_include 'bookmarks', filter[:values].map{|v| v[1]}
end
+ def test_filter_project_parent_id_with_my_projects
+ User.current = User.find(1)
+ query = ProjectQuery.new(:name => '_')
+ filter = query.available_filters['parent_id']
+ assert_not_nil filter
+ assert_include 'mine', filter[:values].map{|v| v[1]}
+
+ query.filters = { 'parent_id' => {:operator => '=', :values => ['mine']}}
+ result = query.results_scope
+
+ my_projects = User.current.memberships.map(&:project_id)
+ assert_equal Project.where(parent_id: my_projects).ids, result.map(&:id).sort
+ end
+
+ def test_filter_project_parent_id_with_my_bookmarks
+ User.current = User.find(1)
+ query = ProjectQuery.new(:name => '_')
+ filter = query.available_filters['parent_id']
+ assert_not_nil filter
+ assert_include 'bookmarks', filter[:values].map{|v| v[1]}
+
+ query.filters = { 'parent_id' => {:operator => '=', :values => ['bookmarks']}}
+ result = query.results_scope
+
+ bookmarks = User.current.bookmarked_project_ids
+ assert_equal Project.where(parent_id: bookmarks).ids, result.map(&:id).sort
+ end
+
def test_filter_watched_issues
User.current = User.find(1)
query = IssueQuery.new(:name => '_', :filters => { 'watcher_id' => {:operator => '=', :values => ['me']}})