summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/fixtures/user_preferences.yml1
-rw-r--r--test/unit/query_test.rb21
-rw-r--r--test/unit/user_test.rb7
3 files changed, 29 insertions, 0 deletions
diff --git a/test/fixtures/user_preferences.yml b/test/fixtures/user_preferences.yml
index a08c46023..0e739956a 100644
--- a/test/fixtures/user_preferences.yml
+++ b/test/fixtures/user_preferences.yml
@@ -11,6 +11,7 @@ user_preferences_001:
- issuesassignedtome
top:
- calendar
+ :bookmarked_project_ids: "1,5"
id: 1
user_id: 1
diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb
index db0d4c884..3524338eb 100644
--- a/test/unit/query_test.rb
+++ b/test/unit/query_test.rb
@@ -922,6 +922,27 @@ class QueryTest < ActiveSupport::TestCase
assert_nil result.detect {|issue| !User.current.member_of?(issue.project)}
end
+ def test_filter_my_bookmarks
+ User.current = User.find(1)
+ query = ProjectQuery.new(:name => '_')
+ filter = query.available_filters['id']
+ assert_not_nil filter
+ assert_include 'bookmarks', filter[:values].map{|v| v[1]}
+
+ query.filters = { 'id' => {:operator => '=', :values => ['bookmarks']}}
+ result = query.results_scope
+
+ assert_equal [1,5], result.map(&:id).sort
+ end
+
+ def test_filter_my_bookmarks_for_user_without_bookmarked_projects
+ User.current = User.find(2)
+ query = ProjectQuery.new(:name => '_')
+ filter = query.available_filters['id']
+
+ assert_not_include 'bookmarks', filter[:values].map{|v| v[1]}
+ end
+
def test_filter_watched_issues
User.current = User.find(1)
query = IssueQuery.new(:name => '_', :filters => { 'watcher_id' => {:operator => '=', :values => ['me']}})
diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb
index 20e34d99c..d44f35958 100644
--- a/test/unit/user_test.rb
+++ b/test/unit/user_test.rb
@@ -1280,6 +1280,13 @@ class UserTest < ActiveSupport::TestCase
assert_equal user, User.try_to_login(user.login, "unsalted")
end
+ def test_bookmarked_project_ids
+ # User with bookmarked projects
+ assert_equal [1, 5], User.find(1).bookmarked_project_ids
+ # User without bookmarked projects
+ assert_equal [], User.find(2).bookmarked_project_ids
+ end
+
if Object.const_defined?(:OpenID)
def test_setting_identity_url
normalized_open_id_url = 'http://example.com/'