Add ActionCable.deprecator

This commit adds `ActionCable.deprecator`, and adds it to
`Rails.application.deprecators` so that it can be configured via
settings such as `config.active_support.report_deprecations`.
This commit is contained in:
Jonathan Hefner 2022-11-01 14:59:36 -05:00
parent b75fc7b994
commit 5a4eadd51c
4 changed files with 15 additions and 1 deletions

View File

@ -30,7 +30,8 @@ require "zeitwerk"
Zeitwerk::Loader.for_gem.tap do |loader|
loader.ignore(
"#{__dir__}/rails", # Contains generators, templates, docs, etc.
"#{__dir__}/action_cable/gem_version.rb"
"#{__dir__}/action_cable/gem_version.rb",
"#{__dir__}/action_cable/deprecator.rb",
)
loader.do_not_eager_load(
@ -44,6 +45,7 @@ end.setup
module ActionCable
require_relative "action_cable/version"
require_relative "action_cable/deprecator"
INTERNAL = {
message_types: {

View File

@ -0,0 +1,7 @@
# frozen_string_literal: true
module ActionCable
def self.deprecator # :nodoc:
@deprecator ||= ActiveSupport::Deprecation.new
end
end

View File

@ -10,6 +10,10 @@ module ActionCable
config.action_cable.mount_path = ActionCable::INTERNAL[:default_mount_path]
config.action_cable.precompile_assets = true
initializer "action_cable.deprecator" do |app|
app.deprecators[:action_cable] = ActionCable.deprecator
end
initializer "action_cable.helpers" do
ActiveSupport.on_load(:action_view) do
include ActionCable::Helpers::ActionCableHelper

View File

@ -3889,6 +3889,7 @@ module ApplicationTests
app "production"
assert_includes Rails.application.deprecators.each, ActiveSupport::Deprecation.instance
assert_equal ActionCable.deprecator, Rails.application.deprecators[:action_cable]
assert_equal AbstractController.deprecator, Rails.application.deprecators[:action_controller]
assert_equal ActionController.deprecator, Rails.application.deprecators[:action_controller]
assert_equal ActionDispatch.deprecator, Rails.application.deprecators[:action_dispatch]