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>2021-12-20 16:37:47 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-12-20 16:37:47 +0300
commitaee0a117a889461ce8ced6fcf73207fe017f1d99 (patch)
tree891d9ef189227a8445d83f35c1b0fc99573f4380 /spec/initializers
parent8d46af3258650d305f53b819eabf7ab18d22f59e (diff)
Add latest changes from gitlab-org/gitlab@14-6-stable-eev14.6.0-rc42
Diffstat (limited to 'spec/initializers')
-rw-r--r--spec/initializers/forbid_sidekiq_in_transactions_spec.rb38
-rw-r--r--spec/initializers/lograge_spec.rb10
-rw-r--r--spec/initializers/session_store_spec.rb24
-rw-r--r--spec/initializers/validate_database_config_spec.rb3
4 files changed, 69 insertions, 6 deletions
diff --git a/spec/initializers/forbid_sidekiq_in_transactions_spec.rb b/spec/initializers/forbid_sidekiq_in_transactions_spec.rb
new file mode 100644
index 00000000000..6cd15d37ad4
--- /dev/null
+++ b/spec/initializers/forbid_sidekiq_in_transactions_spec.rb
@@ -0,0 +1,38 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'Sidekiq::Worker' do
+ let(:worker_class) do
+ Class.new do
+ include Sidekiq::Worker
+
+ def perform
+ end
+ end
+ end
+
+ it 'allows sidekiq worker outside of a transaction' do
+ expect { worker_class.perform_async }.not_to raise_error
+ end
+
+ it 'forbids queue sidekiq worker in a transaction' do
+ Project.transaction do
+ expect { worker_class.perform_async }.to raise_error(Sidekiq::Worker::EnqueueFromTransactionError)
+ end
+ end
+
+ it 'allows sidekiq worker in a transaction if skipped' do
+ Sidekiq::Worker.skipping_transaction_check do
+ Project.transaction do
+ expect { worker_class.perform_async }.not_to raise_error
+ end
+ end
+ end
+
+ it 'forbids queue sidekiq worker in a Ci::ApplicationRecord transaction' do
+ Ci::Pipeline.transaction do
+ expect { worker_class.perform_async }.to raise_error(Sidekiq::Worker::EnqueueFromTransactionError)
+ end
+ end
+end
diff --git a/spec/initializers/lograge_spec.rb b/spec/initializers/lograge_spec.rb
index 9e58fa289ac..0a794e8ebcd 100644
--- a/spec/initializers/lograge_spec.rb
+++ b/spec/initializers/lograge_spec.rb
@@ -157,6 +157,16 @@ RSpec.describe 'lograge', type: :request do
expect(log_data['exception.message']).to eq('bad request')
expect(log_data['exception.backtrace']).to eq(Gitlab::BacktraceCleaner.clean_backtrace(backtrace))
end
+
+ context 'with an ActiveRecord::StatementInvalid' do
+ let(:exception) { ActiveRecord::StatementInvalid.new(sql: 'SELECT "users".* FROM "users" WHERE "users"."id" = 1 AND "users"."foo" = $1') }
+
+ it 'adds the SQL query to the log' do
+ subscriber.process_action(event)
+
+ expect(log_data['exception.sql']).to eq('SELECT "users".* FROM "users" WHERE "users"."id" = $2 AND "users"."foo" = $1')
+ end
+ end
end
describe 'with etag_route' do
diff --git a/spec/initializers/session_store_spec.rb b/spec/initializers/session_store_spec.rb
index 3da52ccc981..db90b335dc9 100644
--- a/spec/initializers/session_store_spec.rb
+++ b/spec/initializers/session_store_spec.rb
@@ -10,25 +10,37 @@ RSpec.describe 'Session initializer for GitLab' do
end
describe 'config#session_store' do
- context 'when the GITLAB_REDIS_STORE_WITH_SESSION_STORE env is not set' do
+ context 'when the GITLAB_USE_REDIS_SESSIONS_STORE env is not set' do
before do
- stub_env('GITLAB_REDIS_STORE_WITH_SESSION_STORE', nil)
+ stub_env('GITLAB_USE_REDIS_SESSIONS_STORE', nil)
end
- it 'initialized as a redis_store with a proper Redis::Store instance' do
+ it 'initialized with Multistore as ENV var defaults to true' do
expect(subject).to receive(:session_store).with(:redis_store, a_hash_including(redis_store: kind_of(::Redis::Store)))
load_session_store
end
end
- context 'when the GITLAB_REDIS_STORE_WITH_SESSION_STORE env is disabled' do
+ context 'when the GITLAB_USE_REDIS_SESSIONS_STORE env is disabled' do
before do
- stub_env('GITLAB_REDIS_STORE_WITH_SESSION_STORE', false)
+ stub_env('GITLAB_USE_REDIS_SESSIONS_STORE', false)
end
it 'initialized as a redis_store with a proper servers configuration' do
- expect(subject).to receive(:session_store).with(:redis_store, a_hash_including(servers: kind_of(Hash)))
+ expect(subject).to receive(:session_store).with(:redis_store, a_hash_including(redis_store: kind_of(Redis::Store)))
+
+ load_session_store
+ end
+ end
+
+ context 'when the GITLAB_USE_REDIS_SESSIONS_STORE env is enabled' do
+ before do
+ stub_env('GITLAB_USE_REDIS_SESSIONS_STORE', true)
+ end
+
+ it 'initialized as a redis_store with a proper servers configuration' do
+ expect(subject).to receive(:session_store).with(:redis_store, a_hash_including(redis_store: kind_of(::Redis::Store)))
load_session_store
end
diff --git a/spec/initializers/validate_database_config_spec.rb b/spec/initializers/validate_database_config_spec.rb
index 99e4a4b36ee..209d9691350 100644
--- a/spec/initializers/validate_database_config_spec.rb
+++ b/spec/initializers/validate_database_config_spec.rb
@@ -14,6 +14,9 @@ RSpec.describe 'validate database config' do
end
before do
+ allow(File).to receive(:exist?).and_call_original
+ allow(File).to receive(:exist?).with(Rails.root.join("config/database_geo.yml")).and_return(false)
+
# The `AS::ConfigurationFile` calls `read` in `def initialize`
# thus we cannot use `expect_next_instance_of`
# rubocop:disable RSpec/AnyInstanceOf