diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-20 11:43:02 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-10-20 11:43:02 +0300 |
commit | d9ab72d6080f594d0b3cae15f14b3ef2c6c638cb (patch) | |
tree | 2341ef426af70ad1e289c38036737e04b0aa5007 /spec/initializers | |
parent | d6e514dd13db8947884cd58fe2a9c2a063400a9b (diff) |
Add latest changes from gitlab-org/gitlab@14-4-stable-eev14.4.0-rc42
Diffstat (limited to 'spec/initializers')
-rw-r--r-- | spec/initializers/carrierwave_patch_spec.rb | 21 | ||||
-rw-r--r-- | spec/initializers/database_config_spec.rb | 10 | ||||
-rw-r--r-- | spec/initializers/lograge_spec.rb | 38 | ||||
-rw-r--r-- | spec/initializers/zz_metrics_spec.rb | 20 |
4 files changed, 28 insertions, 61 deletions
diff --git a/spec/initializers/carrierwave_patch_spec.rb b/spec/initializers/carrierwave_patch_spec.rb index cbdad4aa9ac..e219db2299d 100644 --- a/spec/initializers/carrierwave_patch_spec.rb +++ b/spec/initializers/carrierwave_patch_spec.rb @@ -81,19 +81,32 @@ RSpec.describe 'CarrierWave::Storage::Fog::File' do end describe '#authenticated_url' do + let(:expire_at) { 24.hours.from_now } + let(:options) { { expire_at: expire_at } } + it 'has an authenticated URL' do - expect(subject.authenticated_url).to eq("https://sa.blob.core.windows.net/test_container/test_blob?token") + expect(subject.authenticated_url(options)).to eq("https://sa.blob.core.windows.net/test_container/test_blob?token") end context 'with custom expire_at' do it 'properly sets expires param' do - expire_at = 24.hours.from_now + expect_next_instance_of(Fog::Storage::AzureRM::File) do |file| + expect(file).to receive(:url).with(expire_at, options).and_call_original + end + + expect(subject.authenticated_url(options)).to eq("https://sa.blob.core.windows.net/test_container/test_blob?token") + end + end + + context 'with content_disposition option' do + let(:options) { { expire_at: expire_at, content_disposition: 'attachment' } } + it 'passes options' do expect_next_instance_of(Fog::Storage::AzureRM::File) do |file| - expect(file).to receive(:url).with(expire_at).and_call_original + expect(file).to receive(:url).with(expire_at, options).and_call_original end - expect(subject.authenticated_url(expire_at: expire_at)).to eq("https://sa.blob.core.windows.net/test_container/test_blob?token") + expect(subject.authenticated_url(options)).to eq("https://sa.blob.core.windows.net/test_container/test_blob?token") end end end diff --git a/spec/initializers/database_config_spec.rb b/spec/initializers/database_config_spec.rb index 5ddfbd64c23..23f7fd06254 100644 --- a/spec/initializers/database_config_spec.rb +++ b/spec/initializers/database_config_spec.rb @@ -2,19 +2,11 @@ require 'spec_helper' -RSpec.describe 'Database config initializer' do +RSpec.describe 'Database config initializer', :reestablished_active_record_base do subject do load Rails.root.join('config/initializers/database_config.rb') end - around do |example| - original_config = ActiveRecord::Base.connection_db_config - - example.run - - ActiveRecord::Base.establish_connection(original_config) - end - before do allow(Gitlab::Runtime).to receive(:max_threads).and_return(max_threads) end diff --git a/spec/initializers/lograge_spec.rb b/spec/initializers/lograge_spec.rb index 4d2aa6e74de..9e58fa289ac 100644 --- a/spec/initializers/lograge_spec.rb +++ b/spec/initializers/lograge_spec.rb @@ -230,39 +230,21 @@ RSpec.describe 'lograge', type: :request do end end - context 'when load balancing is enabled' do - before do - allow(Gitlab::Database::LoadBalancing).to receive(:enable?).and_return(true) - end - - context 'with db payload' do - context 'when RequestStore is enabled', :request_store do - it 'includes db counters for load balancing' do - subscriber.process_action(event) - - expect(log_data).to include(*db_load_balancing_logging_keys) - end - end - - context 'when RequestStore is disabled' do - it 'does not include db counters for load balancing' do - subscriber.process_action(event) + context 'with db payload' do + context 'when RequestStore is enabled', :request_store do + it 'includes db counters for load balancing' do + subscriber.process_action(event) - expect(log_data).not_to include(*db_load_balancing_logging_keys) - end + expect(log_data).to include(*db_load_balancing_logging_keys) end end - end - context 'when load balancing is disabled' do - before do - allow(Gitlab::Database::LoadBalancing).to receive(:enable?).and_return(false) - end + context 'when RequestStore is disabled' do + it 'does not include db counters for load balancing' do + subscriber.process_action(event) - it 'does not include db counters for load balancing' do - subscriber.process_action(event) - - expect(log_data).not_to include(*db_load_balancing_logging_keys) + expect(log_data).not_to include(*db_load_balancing_logging_keys) + end end end end diff --git a/spec/initializers/zz_metrics_spec.rb b/spec/initializers/zz_metrics_spec.rb deleted file mode 100644 index ad93c30ee22..00000000000 --- a/spec/initializers/zz_metrics_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'instrument_classes' do - let(:config) { double(:config) } - - before do - allow(config).to receive(:instrument_method) - allow(config).to receive(:instrument_methods) - allow(config).to receive(:instrument_instance_method) - allow(config).to receive(:instrument_instance_methods) - allow(Gitlab::Application).to receive(:configure) - end - - it 'can autoload and instrument all files' do - require_relative '../../config/initializers/zz_metrics' - expect { instrument_classes(config) }.not_to raise_error - end -end |