Skip to content

Commit

Permalink
fixes #18691 - add as_deprecation_tracker to test environment
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
domcleal authored and dLobatog committed Feb 27, 2017
1 parent 213e806 commit 0fd467c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions bundler.d/test.rb
Expand Up @@ -15,4 +15,5 @@
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
4 changes: 4 additions & 0 deletions config/as_deprecation_whitelist.yaml
@@ -0,0 +1,4 @@
---
# 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.
16 changes: 16 additions & 0 deletions config/environments/test.rb
@@ -1,3 +1,8 @@
# 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.

Expand Down Expand Up @@ -62,4 +67,15 @@
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
1 change: 1 addition & 0 deletions config/initializers/deprecations.rb
@@ -0,0 +1 @@
ActiveSupport::Deprecation.behavior = :silence if Rails.env.production?

0 comments on commit 0fd467c

Please sign in to comment.