]> source.dussan.org Git - redmine.git/commitdiff
Only show currently visible projects in the project jump box (#34595).
authorGo MAEDA <maeda@farend.jp>
Tue, 16 Mar 2021 02:47:09 +0000 (02:47 +0000)
committerGo MAEDA <maeda@farend.jp>
Tue, 16 Mar 2021 02:47:09 +0000 (02:47 +0000)
Patch by Holger Just and Marius BALTEANU.

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

lib/redmine/project_jump_box.rb
test/unit/lib/redmine/project_jump_box_test.rb

index b8f332008ee07191857839d1303aa997857be51d..067cb29449340b0111d8e524c094f87064882aa1 100644 (file)
@@ -31,6 +31,7 @@ module Redmine
     def recently_used_projects
       project_ids = recently_used_project_ids
       Project.where(id: project_ids).
+        visible.
         index_by(&:id).
         values_at(*project_ids). # sort according to stored order
         compact
index 5842354c5a7688c699e2f2bbe5a6d1068209c496..e232a1e933c19a9040f582517f8d1b8ff77ba830 100644 (file)
@@ -23,7 +23,8 @@ class Redmine::ProjectJumpBoxTest < ActiveSupport::TestCase
   fixtures :users, :projects, :user_preferences
 
   def setup
-    @user = User.find_by_login 'dlopper'
+    @user = User.find_by_login 'jsmith'
+    User.current = @user
     @ecookbook = Project.find 'ecookbook'
     @onlinestore = Project.find 'onlinestore'
   end
@@ -134,4 +135,16 @@ class Redmine::ProjectJumpBoxTest < ActiveSupport::TestCase
     assert_equal @onlinestore, pjb.recently_used_projects.first
     assert_equal @ecookbook, pjb.recently_used_projects.last
   end
+
+  def test_recents_list_should_include_only_visible_projects
+    @user = User.find_by_login 'dlopper'
+    User.current = @user
+
+    pjb = Redmine::ProjectJumpBox.new @user
+    pjb.project_used @ecookbook
+    pjb.project_used @onlinestore
+
+    assert_equal 1, pjb.recently_used_projects.size
+    assert_equal @ecookbook, pjb.recently_used_projects.first
+  end
 end