Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/concerns/routable_spec.rb')
-rw-r--r--spec/models/concerns/routable_spec.rb50
1 files changed, 12 insertions, 38 deletions
diff --git a/spec/models/concerns/routable_spec.rb b/spec/models/concerns/routable_spec.rb
index 2b6f8535743..7e324812b97 100644
--- a/spec/models/concerns/routable_spec.rb
+++ b/spec/models/concerns/routable_spec.rb
@@ -3,18 +3,12 @@
require 'spec_helper'
RSpec.shared_examples 'routable resource' do
- shared_examples_for '.find_by_full_path' do
+ shared_examples_for '.find_by_full_path' do |has_cross_join: false|
it 'finds records by their full path' do
expect(described_class.find_by_full_path(record.full_path)).to eq(record)
expect(described_class.find_by_full_path(record.full_path.upcase)).to eq(record)
end
- it 'checks if `optimize_routable` is enabled only once' do
- expect(Routable).to receive(:optimize_routable_enabled?).once
-
- described_class.find_by_full_path(record.full_path)
- end
-
it 'returns nil for unknown paths' do
expect(described_class.find_by_full_path('unknown')).to be_nil
end
@@ -51,27 +45,23 @@ RSpec.shared_examples 'routable resource' do
end
end
end
- end
-
- it_behaves_like '.find_by_full_path', :aggregate_failures
-
- context 'when the `optimize_routable` feature flag is turned OFF' do
- before do
- stub_feature_flags(optimize_routable: false)
- end
- it_behaves_like '.find_by_full_path', :aggregate_failures
+ if has_cross_join
+ it 'has a cross-join' do
+ expect(Gitlab::Database).to receive(:allow_cross_joins_across_databases)
- it 'includes route information when loading a record' do
- control_count = ActiveRecord::QueryRecorder.new do
described_class.find_by_full_path(record.full_path)
- end.count
+ end
+ else
+ it 'does not have cross-join' do
+ expect(Gitlab::Database).not_to receive(:allow_cross_joins_across_databases)
- expect do
- described_class.find_by_full_path(record.full_path).route
- end.not_to exceed_all_query_limit(control_count)
+ described_class.find_by_full_path(record.full_path)
+ end
end
end
+
+ it_behaves_like '.find_by_full_path', :aggregate_failures
end
RSpec.shared_examples 'routable resource with parent' do
@@ -274,22 +264,6 @@ RSpec.describe Namespaces::ProjectNamespace, 'Routable', :with_clean_rails_cache
end
end
-RSpec.describe Routable, feature_category: :groups_and_projects do
- describe '.optimize_routable_enabled?' do
- subject { described_class.optimize_routable_enabled? }
-
- it { is_expected.to eq(true) }
-
- context 'when the `optimize_routable` feature flag is turned OFF' do
- before do
- stub_feature_flags(optimize_routable: false)
- end
-
- it { is_expected.to eq(false) }
- end
- end
-end
-
def forcibly_hit_cached_lookup(record, method)
stub_feature_flags(cached_route_lookups: true)
expect(record).to receive(:persisted?).and_return(true)