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:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-09-30 00:08:27 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-09-30 00:08:27 +0300
commit836ddfc35d1778675b3bd6d51f51972f36a96bbe (patch)
treebc1c0247c76a2cbdbab94b3884bc040b179f41fe /spec/support
parent488e1b59feb4314b034636990bcc4e220e61f0ce (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/database/multiple_databases.rb10
-rw-r--r--spec/support/rspec_order_todo.yml1
-rw-r--r--spec/support/shared_examples/bulk_imports/common/pipelines/wiki_pipeline_examples.rb21
-rw-r--r--spec/support/shared_examples/controllers/concerns/web_hooks/integrations_hook_log_actions_shared_examples.rb2
-rw-r--r--spec/support/shared_examples/lib/sentry/client_shared_examples.rb16
-rw-r--r--spec/support/shared_examples/models/integrations/has_web_hook_shared_examples.rb6
6 files changed, 52 insertions, 4 deletions
diff --git a/spec/support/database/multiple_databases.rb b/spec/support/database/multiple_databases.rb
index 05f26e57e9c..96bdab5171d 100644
--- a/spec/support/database/multiple_databases.rb
+++ b/spec/support/database/multiple_databases.rb
@@ -87,6 +87,16 @@ module Database
end
RSpec.configure do |config|
+ # Ensure database versions are memoized to prevent query counts from
+ # being affected by version checks. Note that
+ # Gitlab::Database.check_postgres_version_and_print_warning is called
+ # at startup, but that generates its own
+ # `Gitlab::Database::Reflection` so the result is not memoized by
+ # callers of `ApplicationRecord.database.version`, such as
+ # `Gitlab::Database::AsWithMaterialized.materialized_supported?`.
+ # TODO This can be removed once https://gitlab.com/gitlab-org/gitlab/-/issues/325639 is completed.
+ [ApplicationRecord, ::Ci::ApplicationRecord].each { |record| record.database.version }
+
config.around(:each, :reestablished_active_record_base) do |example|
with_reestablished_active_record_base(reconnect: example.metadata.fetch(:reconnect, true)) do
example.run
diff --git a/spec/support/rspec_order_todo.yml b/spec/support/rspec_order_todo.yml
index 304b473e55c..d2e9313f660 100644
--- a/spec/support/rspec_order_todo.yml
+++ b/spec/support/rspec_order_todo.yml
@@ -2015,7 +2015,6 @@
- './ee/spec/models/milestone_spec.rb'
- './ee/spec/models/namespace_limit_spec.rb'
- './ee/spec/models/namespace_setting_spec.rb'
-- './ee/spec/models/namespaces/free_user_cap/preview_spec.rb'
- './ee/spec/models/namespaces/free_user_cap_spec.rb'
- './ee/spec/models/namespaces/free_user_cap/standard_spec.rb'
- './ee/spec/models/namespaces/storage/root_excess_size_spec.rb'
diff --git a/spec/support/shared_examples/bulk_imports/common/pipelines/wiki_pipeline_examples.rb b/spec/support/shared_examples/bulk_imports/common/pipelines/wiki_pipeline_examples.rb
index 06800f7cded..7e7460cd602 100644
--- a/spec/support/shared_examples/bulk_imports/common/pipelines/wiki_pipeline_examples.rb
+++ b/spec/support/shared_examples/bulk_imports/common/pipelines/wiki_pipeline_examples.rb
@@ -4,8 +4,9 @@ RSpec.shared_examples 'wiki pipeline imports a wiki for an entity' do
describe '#run' do
let_it_be(:bulk_import_configuration) { create(:bulk_import_configuration, bulk_import: bulk_import) }
- let_it_be(:tracker) { create(:bulk_import_tracker, entity: entity) }
- let_it_be(:context) { BulkImports::Pipeline::Context.new(tracker) }
+ let_it_be_with_reload(:tracker) { create(:bulk_import_tracker, entity: entity) }
+
+ let(:context) { BulkImports::Pipeline::Context.new(tracker) }
let(:extracted_data) { BulkImports::Pipeline::ExtractedData.new(data: {}) }
@@ -40,5 +41,21 @@ RSpec.shared_examples 'wiki pipeline imports a wiki for an entity' do
expect { subject.run }.not_to raise_error
end
end
+
+ context 'when scheme is blocked' do
+ it 'prevents import' do
+ # Force bulk_import_configuration to have a file:// URL
+ bulk_import_configuration.url = 'file://example.com'
+ bulk_import_configuration.save!(validate: false)
+
+ expect(subject).to receive(:source_wiki_exists?).and_return(true)
+
+ subject.run
+
+ expect(tracker.failed?).to eq(true)
+ expect(tracker.entity.failures.first).to be_present
+ expect(tracker.entity.failures.first.exception_message).to eq('Only allowed schemes are http, https')
+ end
+ end
end
end
diff --git a/spec/support/shared_examples/controllers/concerns/web_hooks/integrations_hook_log_actions_shared_examples.rb b/spec/support/shared_examples/controllers/concerns/web_hooks/integrations_hook_log_actions_shared_examples.rb
index 62c9c3508a8..56a5dcb10b2 100644
--- a/spec/support/shared_examples/controllers/concerns/web_hooks/integrations_hook_log_actions_shared_examples.rb
+++ b/spec/support/shared_examples/controllers/concerns/web_hooks/integrations_hook_log_actions_shared_examples.rb
@@ -26,7 +26,7 @@ RSpec.shared_examples WebHooks::HookLogActions do
describe 'POST #retry' do
it 'executes the hook and redirects to the service form' do
- stub_request(:post, web_hook.url)
+ stub_request(:post, web_hook.interpolated_url)
expect_next_found_instance_of(web_hook.class) do |hook|
expect(hook).to receive(:execute).and_call_original
diff --git a/spec/support/shared_examples/lib/sentry/client_shared_examples.rb b/spec/support/shared_examples/lib/sentry/client_shared_examples.rb
index 1c0e0061385..71b32005c55 100644
--- a/spec/support/shared_examples/lib/sentry/client_shared_examples.rb
+++ b/spec/support/shared_examples/lib/sentry/client_shared_examples.rb
@@ -59,6 +59,22 @@ RSpec.shared_examples 'maps Sentry exceptions' do |http_method|
end
end
+RSpec.shared_examples 'non-numeric input handling in Sentry response' do |field|
+ context 'with non-numeric error id' do
+ where(:id_input) do
+ ['string', '-1', '1\n2']
+ end
+
+ with_them do
+ it 'raises exception' do
+ message = %(Sentry API response contains invalid value for field "#{field}": #{id_input.inspect} is not numeric)
+
+ expect { subject }.to raise_error(ErrorTracking::SentryClient::InvalidFieldValueError, message)
+ end
+ end
+ end
+end
+
# Expects to following variables:
# - subject
# - sentry_api_response
diff --git a/spec/support/shared_examples/models/integrations/has_web_hook_shared_examples.rb b/spec/support/shared_examples/models/integrations/has_web_hook_shared_examples.rb
index a341497a456..31ec25249d7 100644
--- a/spec/support/shared_examples/models/integrations/has_web_hook_shared_examples.rb
+++ b/spec/support/shared_examples/models/integrations/has_web_hook_shared_examples.rb
@@ -37,6 +37,12 @@ RSpec.shared_examples Integrations::HasWebHook do
end
end
+ describe '#url_variables' do
+ it 'returns a string' do
+ expect(integration.url_variables).to be_a(Hash)
+ end
+ end
+
describe '#hook_ssl_verification' do
it 'returns a boolean' do
expect(integration.hook_ssl_verification).to be_in([true, false])