diff options
Diffstat (limited to 'spec/initializers/0_log_deprecations_spec.rb')
-rw-r--r-- | spec/initializers/0_log_deprecations_spec.rb | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/spec/initializers/0_log_deprecations_spec.rb b/spec/initializers/0_log_deprecations_spec.rb index 35bceb2f132..f5065126eaf 100644 --- a/spec/initializers/0_log_deprecations_spec.rb +++ b/spec/initializers/0_log_deprecations_spec.rb @@ -3,6 +3,10 @@ require 'spec_helper' RSpec.describe '0_log_deprecations' do + def setup_other_deprecations + Warning.process(__FILE__) { :default } + end + def load_initializer load Rails.root.join('config/initializers/0_log_deprecations.rb') end @@ -11,16 +15,20 @@ RSpec.describe '0_log_deprecations' do before do stub_env('GITLAB_LOG_DEPRECATIONS', env_var) + setup_other_deprecations load_initializer end after do - # reset state changed by initializer - Warning.clear ActiveSupport::Notifications.unsubscribe('deprecation.rails') end - context 'for Ruby deprecations' do + around do |example| + # reset state changed by initializer + Warning.clear(&example) + end + + describe 'Ruby deprecations' do context 'when catching deprecations through Kernel#warn' do it 'also logs them to deprecation logger' do expect(Gitlab::DeprecationJsonLogger).to receive(:info).with( @@ -32,7 +40,7 @@ RSpec.describe '0_log_deprecations' do end end - context 'for other messages from Kernel#warn' do + describe 'other messages from Kernel#warn' do it 'does not log them to deprecation logger' do expect(Gitlab::DeprecationJsonLogger).not_to receive(:info) @@ -51,7 +59,7 @@ RSpec.describe '0_log_deprecations' do end end - context 'for Rails deprecations' do + describe 'Rails deprecations' do it 'logs them to deprecation logger' do expect(Gitlab::DeprecationJsonLogger).to receive(:info).with( message: match(/^DEPRECATION WARNING: ABC will be removed/), |