def project_values
project_values = []
- if User.current.logged? && User.current.memberships.any?
- project_values << ["<< #{l(:label_my_projects).downcase} >>", "mine"]
+ if User.current.logged?
+ project_values << ["<< #{l(:label_my_projects).downcase} >>", "mine"] if User.current.memberships.any?
+ project_values << ["<< #{l(:label_my_bookmarks).downcase} >>", "bookmarks"] if User.current.bookmarked_project_ids.any?
end
project_values += all_projects_values
project_values
if v.delete('mine')
v += User.current.memberships.map(&:project_id).map(&:to_s)
end
+ if v.delete('bookmarks')
+ v += User.current.bookmarked_project_ids
+ end
end
if field =~ /^cf_(\d+)\.cf_(\d+)$/
end
end
+ def bookmarked_project_ids
+ project_ids = []
+ bookmarked_project_ids = self.pref[:bookmarked_project_ids]
+ project_ids = bookmarked_project_ids.split(',') unless bookmarked_project_ids.nil?
+ project_ids.map(&:to_i)
+ end
+
protected
def validate_password_length
label_display_type: Display results as
label_display_type_list: List
label_display_type_board: Board
+ label_my_bookmarks: My bookmarks
button_login: Login
button_submit: Submit
- issuesassignedtome
top:
- calendar
+ :bookmarked_project_ids: "1,5"
id: 1
user_id: 1
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']}})
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/'