Project

General

Profile

« Previous | Next » 

Revision 0fd467c8

Added by Dominic Cleal over 7 years ago

fixes #18691 - add as_deprecation_tracker to test environment

Causes test failures if any new deprecation warnings are triggered by
changes in Foreman. Plugin code is automatically whitelisted unless it
supplies its own ASDT whitelist configuration, so developers can opt-in.

Warnings are now hidden in production as they're only relevant in
development or test environments.

View differences:

bundler.d/test.rb
gem 'test_after_commit', '>= 0.4', '< 2.0'
gem 'shoulda-matchers', '~> 3.0'
gem 'shoulda-context', '~> 1.2'
gem 'as_deprecation_tracker', '~> 1.4'
end
config/as_deprecation_whitelist.yaml
---
# http://projects.theforeman.org/issues/7570
- message: You didn't set `secret_key_base`. Read the upgrade documentation to learn
more about this new config option.
config/environments/test.rb
# Track deprecation warnings in test environment as early as possible, but pause processing of
# deprecations until all plugins are registered (prior to the finisher_hook initializer) to ensure
# the whitelist is fully configured. This is done in the after_initialize block below.
ASDeprecationTracker.pause!
Foreman::Application.configure do
# Settings specified here will take precedence over those in config/application.rb.
......
config.active_support.test_order = :random
config.webpack.dev_server.enabled = false
# Whitelist all plugin engines by default from raising errors on deprecation warnings for
# compatibility, allow them to override it by adding an ASDT configuration file.
config.after_initialize do
Foreman::Plugin.all.each do |plugin|
unless File.exist?(File.join(plugin.path, 'config', 'as_deprecation_whitelist.yaml'))
ASDeprecationTracker.whitelist.add(engine: plugin.id.to_s.gsub('-', '_'))
end
end
ASDeprecationTracker.resume!
end
end
config/initializers/deprecations.rb
ActiveSupport::Deprecation.behavior = :silence if Rails.env.production?

Also available in: Unified diff