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/support')
-rw-r--r--spec/support/helpers/search_helpers.rb4
-rw-r--r--spec/support/rate_limiter.rb7
-rw-r--r--spec/support/rspec_order_todo.yml1
-rw-r--r--spec/support/shared_contexts/lib/sbom/package_url_shared_contexts.rb114
-rw-r--r--spec/support/shared_examples/features/search/search_timeouts_shared_examples.rb8
-rw-r--r--spec/support/shared_examples/quick_actions/issuable/max_issuable_examples.rb75
6 files changed, 77 insertions, 132 deletions
diff --git a/spec/support/helpers/search_helpers.rb b/spec/support/helpers/search_helpers.rb
index 581ef07752e..7d0f8c09933 100644
--- a/spec/support/helpers/search_helpers.rb
+++ b/spec/support/helpers/search_helpers.rb
@@ -33,13 +33,13 @@ module SearchHelpers
end
def select_search_scope(scope)
- page.within '.search-filter' do
+ page.within '[data-testid="search-filter"]' do
click_link scope
end
end
def has_search_scope?(scope)
- page.within '.search-filter' do
+ page.within '[data-testid="search-filter"]' do
has_link?(scope)
end
end
diff --git a/spec/support/rate_limiter.rb b/spec/support/rate_limiter.rb
new file mode 100644
index 00000000000..525d593c293
--- /dev/null
+++ b/spec/support/rate_limiter.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+RSpec.configure do |config|
+ config.before(:each, :disable_rate_limiter) do
+ allow(Gitlab::ApplicationRateLimiter).to receive(:throttled?).and_return(false)
+ end
+end
diff --git a/spec/support/rspec_order_todo.yml b/spec/support/rspec_order_todo.yml
index f9d61117ef6..67b7023f1ff 100644
--- a/spec/support/rspec_order_todo.yml
+++ b/spec/support/rspec_order_todo.yml
@@ -997,7 +997,6 @@
- './ee/spec/graphql/types/vulnerability_severity_enum_spec.rb'
- './ee/spec/graphql/types/vulnerability_sort_enum_spec.rb'
- './ee/spec/graphql/types/vulnerability_state_enum_spec.rb'
-- './ee/spec/graphql/types/vulnerability_type_spec.rb'
- './ee/spec/graphql/types/vulnerable_dependency_type_spec.rb'
- './ee/spec/graphql/types/vulnerable_kubernetes_resource_type_spec.rb'
- './ee/spec/graphql/types/vulnerable_package_type_spec.rb'
diff --git a/spec/support/shared_contexts/lib/sbom/package_url_shared_contexts.rb b/spec/support/shared_contexts/lib/sbom/package_url_shared_contexts.rb
index b5c9e9cc7b0..263cf9f5e19 100644
--- a/spec/support/shared_contexts/lib/sbom/package_url_shared_contexts.rb
+++ b/spec/support/shared_contexts/lib/sbom/package_url_shared_contexts.rb
@@ -1,98 +1,26 @@
# frozen_string_literal: true
-RSpec.shared_context 'with purl matrix' do
+require 'oj'
+
+def parameterized_test_matrix(invalid: false)
+ test_cases_path = File.join(
+ File.expand_path(__dir__), '..', '..', '..', '..', 'fixtures', 'lib', 'sbom', 'package-url-test-cases.json')
+ test_cases = Gitlab::Json.parse(File.read(test_cases_path))
+
+ test_cases.filter { _1.delete('is_invalid') == invalid }.each_with_object({}) do |test_case, memo|
+ description = test_case.delete('description')
+ memo[description] = test_case.symbolize_keys
+ end
+end
+
+RSpec.shared_context 'with valid purl examples' do
+ where do
+ parameterized_test_matrix(invalid: false)
+ end
+end
+
+RSpec.shared_context 'with invalid purl examples' do
where do
- {
- 'valid RubyGems package URL' => {
- url: 'pkg:gem/ruby-advisory-db-check@0.12.4',
- type: 'gem',
- namespace: nil,
- name: 'ruby-advisory-db-check',
- version: '0.12.4',
- qualifiers: nil,
- subpath: nil
- },
- 'valid BitBucket package URL' => {
- url: 'pkg:bitbucket/birkenfeld/pygments-main@244fd47e07d1014f0aed9c',
- type: 'bitbucket',
- namespace: 'birkenfeld',
- name: 'pygments-main',
- version: '244fd47e07d1014f0aed9c',
- qualifiers: nil,
- subpath: nil
- },
- 'valid GitHub package URL' => {
- url: 'pkg:github/package-url/purl-spec@244fd47e07d1004f0aed9c',
- type: 'github',
- namespace: 'package-url',
- name: 'purl-spec',
- version: '244fd47e07d1004f0aed9c',
- qualifiers: nil,
- subpath: nil
- },
- 'valid Go module URL' => {
- url: 'pkg:golang/google.golang.org/genproto#googleapis/api/annotations',
- type: 'golang',
- namespace: 'google.golang.org',
- name: 'genproto',
- version: nil,
- qualifiers: nil,
- subpath: 'googleapis/api/annotations'
- },
- 'valid Maven package URL' => {
- url: 'pkg:maven/org.apache.commons/io@1.3.4',
- type: 'maven',
- namespace: 'org.apache.commons',
- name: 'io',
- version: '1.3.4',
- qualifiers: nil,
- subpath: nil
- },
- 'valid NPM package URL' => {
- url: 'pkg:npm/foobar@12.3.1',
- type: 'npm',
- namespace: nil,
- name: 'foobar',
- version: '12.3.1',
- qualifiers: nil,
- subpath: nil
- },
- 'valid NuGet package URL' => {
- url: 'pkg:nuget/EnterpriseLibrary.Common@6.0.1304',
- type: 'nuget',
- namespace: nil,
- name: 'EnterpriseLibrary.Common',
- version: '6.0.1304',
- qualifiers: nil,
- subpath: nil
- },
- 'valid PyPI package URL' => {
- url: 'pkg:pypi/django@1.11.1',
- type: 'pypi',
- namespace: nil,
- name: 'django',
- version: '1.11.1',
- qualifiers: nil,
- subpath: nil
- },
- 'valid RPM package URL' => {
- url: 'pkg:rpm/fedora/curl@7.50.3-1.fc25?arch=i386&distro=fedora-25',
- type: 'rpm',
- namespace: 'fedora',
- name: 'curl',
- version: '7.50.3-1.fc25',
- qualifiers: { 'arch' => 'i386', 'distro' => 'fedora-25' },
- subpath: nil
- },
- 'package URL with checksums' => {
- url: 'pkg:rpm/name?checksums=a,b,c',
- type: 'rpm',
- namespace: nil,
- name: 'name',
- version: nil,
- qualifiers: { 'checksums' => %w[a b c] },
- subpath: nil
- }
- }
+ parameterized_test_matrix(invalid: true)
end
end
diff --git a/spec/support/shared_examples/features/search/search_timeouts_shared_examples.rb b/spec/support/shared_examples/features/search/search_timeouts_shared_examples.rb
index 84dc2b20ddc..cc74c977064 100644
--- a/spec/support/shared_examples/features/search/search_timeouts_shared_examples.rb
+++ b/spec/support/shared_examples/features/search/search_timeouts_shared_examples.rb
@@ -1,23 +1,23 @@
# frozen_string_literal: true
RSpec.shared_examples 'search timeouts' do |scope|
+ let(:additional_params) { {} }
+
context 'when search times out' do
before do
- stub_feature_flags(search_page_vertical_nav: false)
allow_next_instance_of(SearchService) do |service|
allow(service).to receive(:search_objects).and_raise(ActiveRecord::QueryCanceled)
end
- visit(search_path(search: 'test', scope: scope))
+ visit(search_path(search: 'test', scope: scope, **additional_params))
end
it 'renders timeout information' do
- # expect(page).to have_content('This endpoint has been requested too many times.')
expect(page).to have_content('Your search timed out')
end
it 'sets tab count to 0' do
- expect(page.find('.search-filter .active')).to have_text('0')
+ expect(page.find('[data-testid="search-filter"] .active')).to have_text('0')
end
end
end
diff --git a/spec/support/shared_examples/quick_actions/issuable/max_issuable_examples.rb b/spec/support/shared_examples/quick_actions/issuable/max_issuable_examples.rb
index e725de8ad31..f5431b29ee2 100644
--- a/spec/support/shared_examples/quick_actions/issuable/max_issuable_examples.rb
+++ b/spec/support/shared_examples/quick_actions/issuable/max_issuable_examples.rb
@@ -12,49 +12,60 @@ RSpec.shared_examples 'does not exceed the issuable size limit' do
project.add_maintainer(user3)
end
- context 'when feature flag is turned on' do
- context "when the number of users of issuable does exceed the limit" do
- before do
- stub_const("Issuable::MAX_NUMBER_OF_ASSIGNEES_OR_REVIEWERS", 2)
+ context "when the number of users of issuable does exceed the limit" do
+ before do
+ stub_const("Issuable::MAX_NUMBER_OF_ASSIGNEES_OR_REVIEWERS", 2)
+ end
+
+ it 'will not add more than the allowed number of users' do
+ allow_next_instance_of(update_service) do |service|
+ expect(service).not_to receive(:execute)
end
- it 'will not add more than the allowed number of users' do
- allow_next_instance_of(update_service) do |service|
- expect(service).not_to receive(:execute)
- end
+ note = described_class.new(project, user, opts.merge(
+ note: note_text,
+ noteable_type: noteable_type,
+ noteable_id: issuable.id,
+ confidential: false
+ )).execute
- note = described_class.new(project, user, opts.merge(
- note: note_text,
- noteable_type: noteable_type,
- noteable_id: issuable.id,
- confidential: false
- )).execute
+ expect(note.errors[:validation]).to match_array([validation_message])
+ end
+ end
- expect(note.errors[:validation]).to match_array([validation_message])
- end
+ context "when the number of users does not exceed the limit" do
+ before do
+ stub_const("Issuable::MAX_NUMBER_OF_ASSIGNEES_OR_REVIEWERS", 6)
end
- context "when the number of users does not exceed the limit" do
- before do
- stub_const("Issuable::MAX_NUMBER_OF_ASSIGNEES_OR_REVIEWERS", 6)
+ it 'calls execute and does not return an error' do
+ allow_next_instance_of(update_service) do |service|
+ expect(service).to receive(:execute).and_call_original
end
- it 'calls execute and does not return an error' do
- allow_next_instance_of(update_service) do |service|
- expect(service).to receive(:execute).and_call_original
- end
-
- note = described_class.new(project, user, opts.merge(
- note: note_text,
- noteable_type: noteable_type,
- noteable_id: issuable.id,
- confidential: false
- )).execute
+ note = described_class.new(project, user, opts.merge(
+ note: note_text,
+ noteable_type: noteable_type,
+ noteable_id: issuable.id,
+ confidential: false
+ )).execute
- expect(note.errors[:validation]).to be_empty
- end
+ expect(note.errors[:validation]).to be_empty
end
end
+end
+
+RSpec.shared_examples 'does not exceed the issuable size limit with ff off' do
+ let(:user1) { create(:user) }
+ let(:user2) { create(:user) }
+ let(:user3) { create(:user) }
+
+ before do
+ project.add_maintainer(user)
+ project.add_maintainer(user1)
+ project.add_maintainer(user2)
+ project.add_maintainer(user3)
+ end
context 'when feature flag is off' do
before do