diff --git a/ee/app/models/search/zoekt.rb b/ee/app/models/search/zoekt.rb index c1c9a6d0c83232ac5d8295a75d24ace1ac0d678a..cae6787ee60d432d0de144f5468de56e3ebfe2f1 100644 --- a/ee/app/models/search/zoekt.rb +++ b/ee/app/models/search/zoekt.rb @@ -23,7 +23,7 @@ def index?(container) root_namespace_id = fetch_root_namespace_id(container) return false unless root_namespace_id - ::Search::Zoekt::EnabledNamespace.for_root_namespace_id(root_namespace_id).exists? + ::Search::Zoekt::Index.for_root_namespace_id(root_namespace_id).exists? end private diff --git a/ee/spec/models/search/zoekt_spec.rb b/ee/spec/models/search/zoekt_spec.rb index 78f012e4d7f0f6943113c0c08e32bf22bbd2a493..29255ef7e7a894302f6f451d5a42624e69461a8e 100644 --- a/ee/spec/models/search/zoekt_spec.rb +++ b/ee/spec/models/search/zoekt_spec.rb @@ -12,6 +12,11 @@ create(:zoekt_index, :ready, zoekt_enabled_namespace: enabled_namespace, node: node) end + let_it_be(:unassigned_group) { create(:group) } + let_it_be_with_reload(:enabled_namespace_without_index) do + create(:zoekt_enabled_namespace, namespace: unassigned_group) + end + describe '#fetch_node_id' do subject(:fetch_node_id) { described_class.fetch_node_id(container) } @@ -131,7 +136,7 @@ it { is_expected.to eq(true) } end - context 'when Zoekt::EnabledNamespace not found' do + context 'when Zoekt::Index is not found' do let(:container) { build(:project) } it { is_expected.to eq(false) } @@ -142,5 +147,11 @@ it { expect { index }.to raise_error(ArgumentError) } end + + context 'when group is unassigned' do + let(:container) { unassigned_group } + + it { is_expected.to eq(false) } + end end end diff --git a/ee/spec/workers/search/zoekt/default_branch_changed_worker_spec.rb b/ee/spec/workers/search/zoekt/default_branch_changed_worker_spec.rb index 330249cec691b7e4b699e24919a0ffabd4fbbccb..5ef2a59db61a5cfdfd3139351bf2794e7c890538 100644 --- a/ee/spec/workers/search/zoekt/default_branch_changed_worker_spec.rb +++ b/ee/spec/workers/search/zoekt/default_branch_changed_worker_spec.rb @@ -5,6 +5,9 @@ RSpec.describe ::Search::Zoekt::DefaultBranchChangedWorker, feature_category: :global_search do let_it_be(:zoekt_enabled_namespace) { create(:zoekt_enabled_namespace) } let_it_be(:project) { create(:project, :repository, namespace: zoekt_enabled_namespace.namespace) } + let_it_be(:index) do + create(:zoekt_index, :ready, zoekt_enabled_namespace: zoekt_enabled_namespace, node: create(:zoekt_node)) + end let(:default_branch_changed_event) { Repositories::DefaultBranchChangedEvent.new(data: data) } let(:container) { project }