Commit 7ea96af5 authored by Imre Farkas's avatar Imre Farkas

Avoid using linear queries when traversal_ids is blank

parent 631f94b9
...@@ -52,7 +52,9 @@ module Namespaces ...@@ -52,7 +52,9 @@ module Namespaces
end end
def use_traversal_ids? def use_traversal_ids?
Feature.enabled?(:use_traversal_ids, root_ancestor, default_enabled: :yaml) return false unless Feature.enabled?(:use_traversal_ids, root_ancestor, default_enabled: :yaml)
traversal_ids.present?
end end
def self_and_descendants def self_and_descendants
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Gitlab::ObjectHierarchy do RSpec.describe Gitlab::ObjectHierarchy do
let_it_be(:parent) { create(:group) } let_it_be(:parent, reload: true) { create(:group) }
let_it_be(:child1) { create(:group, parent: parent) } let_it_be(:child1) { create(:group, parent: parent) }
let_it_be(:child2) { create(:group, parent: child1) } let_it_be(:child2) { create(:group, parent: child1) }
......
...@@ -880,7 +880,7 @@ RSpec.describe Namespace do ...@@ -880,7 +880,7 @@ RSpec.describe Namespace do
end end
describe '#use_traversal_ids?' do describe '#use_traversal_ids?' do
let_it_be(:namespace) { build(:namespace) } let_it_be(:namespace, reload: true) { create(:namespace) }
subject { namespace.use_traversal_ids? } subject { namespace.use_traversal_ids? }
...@@ -902,6 +902,8 @@ RSpec.describe Namespace do ...@@ -902,6 +902,8 @@ RSpec.describe Namespace do
end end
context 'when use_traversal_ids feature flag is true' do context 'when use_traversal_ids feature flag is true' do
let_it_be(:namespace, reload: true) { create(:namespace) }
it_behaves_like 'namespace traversal' it_behaves_like 'namespace traversal'
describe '#self_and_descendants' do describe '#self_and_descendants' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment