summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/frontend/snippets/components/snippet_header_spec.js4
-rw-r--r--spec/graphql/types/base_field_spec.rb11
-rw-r--r--spec/lib/gitlab/import_export/all_models.yml1
-rw-r--r--spec/lib/gitlab/polling_interval_spec.rb32
-rw-r--r--spec/requests/api/graphql_spec.rb13
-rw-r--r--spec/rubocop/cop/filename_length_spec.rb51
-rw-r--r--spec/views/layouts/nav/sidebar/_admin.html.haml_spec.rb16
-rw-r--r--spec/workers/concerns/waitable_worker_spec.rb26
8 files changed, 128 insertions, 26 deletions
diff --git a/spec/frontend/snippets/components/snippet_header_spec.js b/spec/frontend/snippets/components/snippet_header_spec.js
index c74f7615538..16a66c70d6a 100644
--- a/spec/frontend/snippets/components/snippet_header_spec.js
+++ b/spec/frontend/snippets/components/snippet_header_spec.js
@@ -32,7 +32,9 @@ describe('Snippet header component', () => {
const errorMsg = 'Foo bar';
const err = { message: errorMsg };
- const resolveMutate = jest.fn(() => Promise.resolve({ data: {} }));
+ const resolveMutate = jest.fn(() =>
+ Promise.resolve({ data: { destroySnippet: { errors: [] } } }),
+ );
const rejectMutation = jest.fn(() => Promise.reject(err));
const mutationTypes = {
diff --git a/spec/graphql/types/base_field_spec.rb b/spec/graphql/types/base_field_spec.rb
index 915700f6437..a3015a34afe 100644
--- a/spec/graphql/types/base_field_spec.rb
+++ b/spec/graphql/types/base_field_spec.rb
@@ -67,17 +67,6 @@ describe Types::BaseField do
expect(field.to_graphql.complexity.call({}, { first: 1 }, 2)).to eq 2
expect(field.to_graphql.complexity.call({}, { first: 1, foo: true }, 2)).to eq 4
end
-
- context 'when graphql_resolver_complexity is disabled' do
- before do
- stub_feature_flags(graphql_resolver_complexity: false)
- end
-
- it 'sets default field complexity' do
- expect(field.to_graphql.complexity.call({}, {}, 2)).to eq 1
- expect(field.to_graphql.complexity.call({}, { first: 50 }, 2)).to eq 1
- end
- end
end
context 'and is not a connection' do
diff --git a/spec/lib/gitlab/import_export/all_models.yml b/spec/lib/gitlab/import_export/all_models.yml
index eb28e730499..b3f279344b1 100644
--- a/spec/lib/gitlab/import_export/all_models.yml
+++ b/spec/lib/gitlab/import_export/all_models.yml
@@ -431,6 +431,7 @@ project:
- sourced_pipelines
- prometheus_metrics
- vulnerabilities
+- vulnerability_exports
- vulnerability_findings
- vulnerability_feedback
- vulnerability_identifiers
diff --git a/spec/lib/gitlab/polling_interval_spec.rb b/spec/lib/gitlab/polling_interval_spec.rb
index 979164269bd..31569b2c51e 100644
--- a/spec/lib/gitlab/polling_interval_spec.rb
+++ b/spec/lib/gitlab/polling_interval_spec.rb
@@ -33,4 +33,36 @@ describe Gitlab::PollingInterval do
end
end
end
+
+ describe '.set_api_header' do
+ let(:context) { double(Grape::Endpoint) }
+
+ before do
+ allow(context).to receive(:header)
+ end
+
+ context 'when polling is disabled' do
+ before do
+ stub_application_setting(polling_interval_multiplier: 0)
+ end
+
+ it 'sets value to -1' do
+ expect(context).to receive(:header).with('Poll-Interval', '-1')
+
+ polling_interval.set_api_header(context, interval: 10_000)
+ end
+ end
+
+ context 'when polling is enabled' do
+ before do
+ stub_application_setting(polling_interval_multiplier: 0.33333)
+ end
+
+ it 'applies modifier to base interval' do
+ expect(context).to receive(:header).with('Poll-Interval', '3333')
+
+ polling_interval.set_api_header(context, interval: 10_000)
+ end
+ end
+ end
end
diff --git a/spec/requests/api/graphql_spec.rb b/spec/requests/api/graphql_spec.rb
index 92c5c52be7d..783dd730dd9 100644
--- a/spec/requests/api/graphql_spec.rb
+++ b/spec/requests/api/graphql_spec.rb
@@ -165,7 +165,6 @@ describe 'GraphQL' do
before do
stub_const('GitlabSchema::DEFAULT_MAX_COMPLEXITY', 6)
- stub_feature_flags(graphql_resolver_complexity: true)
end
context 'when fetching single resource' do
@@ -186,18 +185,6 @@ describe 'GraphQL' do
expect_graphql_errors_to_include(/which exceeds max complexity/)
end
-
- context 'when graphql_resolver_complexity is disabled' do
- before do
- stub_feature_flags(graphql_resolver_complexity: false)
- end
-
- it 'processes the query' do
- post_graphql(query)
-
- expect(graphql_errors).to be_nil
- end
- end
end
end
end
diff --git a/spec/rubocop/cop/filename_length_spec.rb b/spec/rubocop/cop/filename_length_spec.rb
new file mode 100644
index 00000000000..1a665440cbc
--- /dev/null
+++ b/spec/rubocop/cop/filename_length_spec.rb
@@ -0,0 +1,51 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require 'rubocop'
+require 'rubocop/rspec/support'
+require_relative '../../../rubocop/cop/filename_length'
+require_relative '../../support/helpers/expect_offense'
+
+describe RuboCop::Cop::FilenameLength do
+ subject(:cop) { described_class.new }
+
+ it 'does not flag files with names 100 characters long' do
+ expect_no_offenses('puts "it does not matter"', 'a' * 100)
+ end
+
+ it 'tags files with names 101 characters long' do
+ filename = 'a' * 101
+
+ expect_offense(<<~SOURCE, filename)
+ source code
+ ^ This file name is too long. It should be 100 or less
+ SOURCE
+ end
+
+ it 'tags files with names 256 characters long' do
+ filename = 'a' * 256
+
+ expect_offense(<<~SOURCE, filename)
+ source code
+ ^ This file name is too long. It should be 100 or less
+ SOURCE
+ end
+
+ it 'tags files with filepath 256 characters long' do
+ filepath = File.join 'a', 'b' * 254
+
+ expect_offense(<<~SOURCE, filepath)
+ source code
+ ^ This file name is too long. It should be 100 or less
+ SOURCE
+ end
+
+ it 'tags files with filepath 257 characters long' do
+ filepath = File.join 'a', 'b' * 255
+
+ expect_offense(<<~SOURCE, filepath)
+ source code
+ ^ This file path is too long. It should be 256 or less
+ SOURCE
+ end
+end
diff --git a/spec/views/layouts/nav/sidebar/_admin.html.haml_spec.rb b/spec/views/layouts/nav/sidebar/_admin.html.haml_spec.rb
index 9ec65dba586..aee2b0baf92 100644
--- a/spec/views/layouts/nav/sidebar/_admin.html.haml_spec.rb
+++ b/spec/views/layouts/nav/sidebar/_admin.html.haml_spec.rb
@@ -91,4 +91,20 @@ describe 'layouts/nav/sidebar/_admin' do
it_behaves_like 'page has active tab', 'Monitoring'
it_behaves_like 'page has active sub tab', 'Background Jobs'
end
+
+ context 'on settings' do
+ before do
+ render
+ end
+
+ it 'includes General link' do
+ expect(rendered).to have_link('General', href: general_admin_application_settings_path)
+ end
+
+ context 'when GitLab FOSS' do
+ it 'does not include Templates link' do
+ expect(rendered).not_to have_link('Templates', href: '/admin/application_settings/templates')
+ end
+ end
+ end
end
diff --git a/spec/workers/concerns/waitable_worker_spec.rb b/spec/workers/concerns/waitable_worker_spec.rb
index 37fadd6ac02..1d76480ccb0 100644
--- a/spec/workers/concerns/waitable_worker_spec.rb
+++ b/spec/workers/concerns/waitable_worker_spec.rb
@@ -44,11 +44,35 @@ describe WaitableWorker do
expect(worker.counter).to eq(6)
end
- it 'runs > 3 jobs using sidekiq' do
+ it 'runs > 3 jobs using sidekiq and a waiter key' do
expect(worker).to receive(:bulk_perform_async)
+ .with([[1, anything], [2, anything], [3, anything], [4, anything]])
worker.bulk_perform_and_wait([[1], [2], [3], [4]])
end
+
+ it 'runs > 10 * timeout jobs using sidekiq and no waiter key' do
+ arguments = 1.upto(21).map { |i| [i] }
+
+ expect(worker).to receive(:bulk_perform_async).with(arguments)
+
+ worker.bulk_perform_and_wait(arguments, timeout: 2)
+ end
+
+ context 'when the skip_job_waiter_for_large_batches flag is disabled' do
+ before do
+ stub_feature_flags(skip_job_waiter_for_large_batches: false)
+ end
+
+ it 'runs jobs over 10 * the timeout using a waiter key' do
+ arguments = 1.upto(21).map { |i| [i] }
+ arguments_with_waiter = arguments.map { |arg| arg + [anything] }
+
+ expect(worker).to receive(:bulk_perform_async).with(arguments_with_waiter)
+
+ worker.bulk_perform_and_wait(arguments, timeout: 2)
+ end
+ end
end
describe '.bulk_perform_inline' do