diff --git a/app/services/search/global_service.rb b/app/services/search/global_service.rb index f711839e389..18a90c952fa 100644 --- a/app/services/search/global_service.rb +++ b/app/services/search/global_service.rb @@ -18,7 +18,7 @@ module Search end def projects - @projects ||= ProjectsFinder.new(current_user: current_user).execute + @projects ||= ProjectsFinder.new(params: { non_archived: true }, current_user: current_user).execute end def allowed_scopes diff --git a/changelogs/unreleased/issue-64738.yml b/changelogs/unreleased/issue-64738.yml new file mode 100644 index 00000000000..0a65ebc750b --- /dev/null +++ b/changelogs/unreleased/issue-64738.yml @@ -0,0 +1,5 @@ +--- +title: Prevent archived projects from showing up in global search +merge_request: 31498 +author: David Palubin +type: fixed diff --git a/spec/services/search/global_service_spec.rb b/spec/services/search/global_service_spec.rb index 62a70ccd3da..0f829df90b3 100644 --- a/spec/services/search/global_service_spec.rb +++ b/spec/services/search/global_service_spec.rb @@ -42,6 +42,14 @@ describe Search::GlobalService do expect(results.objects('projects')).to match_array [found_project] end + + it 'does not return archived projects' do + archived_project = create(:project, :public, archived: true, name: 'archived_project') + + results = described_class.new(user, search: "archived").execute + + expect(results.objects('projects')).not_to include(archived_project) + end end end end