]> source.dussan.org Git - redmine.git/commitdiff
Support "my bookmarks" in the search (#38459).
authorGo MAEDA <maeda@farend.jp>
Tue, 18 Apr 2023 14:45:47 +0000 (14:45 +0000)
committerGo MAEDA <maeda@farend.jp>
Tue, 18 Apr 2023 14:45:47 +0000 (14:45 +0000)
Patch by Go MAEDA.

git-svn-id: https://svn.redmine.org/redmine/trunk@22204 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/search_controller.rb
app/helpers/search_helper.rb
test/functional/search_controller_test.rb

index b9ff59e90047eb2c682238a788bde188ac3458bd..a13b9932e4eb25617f5fa88a08c375346ff161bd 100644 (file)
@@ -49,6 +49,8 @@ class SearchController < ApplicationController
         nil
       when 'my_projects'
         User.current.projects
+      when 'bookmarks'
+        Project.where(id: User.current.bookmarked_project_ids)
       when 'subprojects'
         @project ? (@project.self_and_descendants.to_a) : nil
       else
index 61331d728dba09c866bf81a726afc25d124a8a15..d55cc14aac6396b1c763855f1d9133b7e3fcd7d7 100644 (file)
@@ -47,6 +47,7 @@ module SearchHelper
   def project_select_tag
     options = [[l(:label_project_all), 'all']]
     options << [l(:label_my_projects), 'my_projects'] unless User.current.memberships.empty?
+    options << [l(:label_my_bookmarks), 'bookmarks'] unless User.current.bookmarked_project_ids.empty?
     options << [l(:label_and_its_subprojects, @project.name), 'subprojects'] unless @project.nil? || @project.descendants.active.empty?
     options << [@project.name, ''] unless @project.nil?
     label_tag("scope", l(:description_project_scope), :class => "hidden-for-sighted") +
index 022ad29e9f1417ff53a82de6fe480e02e65494b1..ee5db12325b2644867df014cda1373a7013f968b 100644 (file)
@@ -171,6 +171,19 @@ class SearchControllerTest < Redmine::ControllerTest
     end
   end
 
+  def test_search_my_bookmarks
+    @request.session[:user_id] = 1
+    get :index, :params => {:q => 'project', :scope => 'bookmarks', :all_words => ''}
+    assert_response :success
+
+    assert_select '#search-results' do
+      assert_select 'dt.issue', :count => 1
+      assert_select 'dt.issue', :text => /Bug #6/
+      assert_select 'dt.changeset', :count => 1
+      assert_select 'dt.changeset', :text => /Revision 4/
+    end
+  end
+
   def test_search_project_and_subprojects
     get :index, :params => {:id => 1, :q => 'recipe subproject', :scope => 'subprojects', :all_words => ''}
     assert_response :success