diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-01 12:08:08 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-01 12:08:08 +0000 |
commit | 2828f81d2a41f46b89e13dc057b982f27aeee547 (patch) | |
tree | 742120cc334d018efe38a3974fd59a67869acc6d /spec/support/shared_examples/lib/gitlab | |
parent | 4def415fbf45e0693b17ea418d378d62ab03a146 (diff) | |
download | gitlab-ce-2828f81d2a41f46b89e13dc057b982f27aeee547.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support/shared_examples/lib/gitlab')
-rw-r--r-- | spec/support/shared_examples/lib/gitlab/ci/ci_trace_shared_examples.rb | 3 | ||||
-rw-r--r-- | spec/support/shared_examples/lib/gitlab/search_language_filter_shared_examples.rb | 54 |
2 files changed, 55 insertions, 2 deletions
diff --git a/spec/support/shared_examples/lib/gitlab/ci/ci_trace_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/ci/ci_trace_shared_examples.rb index 284c129221b..b786d7e5527 100644 --- a/spec/support/shared_examples/lib/gitlab/ci/ci_trace_shared_examples.rb +++ b/spec/support/shared_examples/lib/gitlab/ci/ci_trace_shared_examples.rb @@ -265,10 +265,9 @@ RSpec.shared_examples 'common trace features' do end context 'build token' do - let(:token) { 'my_secret_token' } + let(:token) { build.token } before do - build.update!(token: token) trace.append(token, 0) end diff --git a/spec/support/shared_examples/lib/gitlab/search_language_filter_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/search_language_filter_shared_examples.rb new file mode 100644 index 00000000000..a3e4379f4d3 --- /dev/null +++ b/spec/support/shared_examples/lib/gitlab/search_language_filter_shared_examples.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true + +RSpec.shared_examples 'search results filtered by language' do + let(:scope) { 'blobs' } + let(:filters) { { language: %w[Ruby Markdown] } } + let(:query) { 'def | popen | test' } + + before do + project.repository.index_commits_and_blobs + + ensure_elasticsearch_index! + end + + subject(:blob_results) { results.objects('blobs') } + + it 'filters by language', :sidekiq_inline, :aggregate_failures do + expected_paths = %w[ + files/ruby/popen.rb + files/markdown/ruby-style-guide.md + files/ruby/regex.rb + files/ruby/version_info.rb + CONTRIBUTING.md + ] + + paths = blob_results.map { |blob| blob.binary_path } + expect(blob_results.size).to eq(5) + expect(paths).to match_array(expected_paths) + end + + context 'when the search_blobs_language_aggregation feature flag is disabled' do + before do + stub_feature_flags(search_blobs_language_aggregation: false) + end + + it 'does not filter by language', :sidekiq_inline, :aggregate_failures do + expected_paths = %w[ + CHANGELOG + CONTRIBUTING.md + bar/branch-test.txt + custom-highlighting/test.gitlab-custom + files/ruby/popen.rb + files/ruby/regex.rb + files/ruby/version_info.rb + files/whitespace + encoding/test.txt + files/markdown/ruby-style-guide.md + ] + + paths = blob_results.map { |blob| blob.binary_path } + expect(blob_results.size).to eq(10) + expect(paths).to match_array(expected_paths) + end + end +end |