mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Use public Module#include, in favor of https://bugs.ruby-lang.org/issues/8846
ref: https://github.com/rails/rails/pull/18763#issuecomment-72349769
This commit is contained in:
parent
c46c1c1599
commit
ce8efcf296
22 changed files with 32 additions and 32 deletions
|
@ -15,7 +15,7 @@ require 'mail'
|
|||
|
||||
# Emulate AV railtie
|
||||
require 'action_view'
|
||||
ActionMailer::Base.send(:include, ActionView::Layouts)
|
||||
ActionMailer::Base.include(ActionView::Layouts)
|
||||
|
||||
# Show backtraces for deprecated behavior for quicker cleanup.
|
||||
ActiveSupport::Deprecation.debug = true
|
||||
|
|
|
@ -6,9 +6,9 @@ module AbstractController
|
|||
define_method(:inherited) do |klass|
|
||||
super(klass)
|
||||
if namespace = klass.parents.detect { |m| m.respond_to?(:railtie_routes_url_helpers) }
|
||||
klass.send(:include, namespace.railtie_routes_url_helpers(include_path_helpers))
|
||||
klass.include(namespace.railtie_routes_url_helpers(include_path_helpers))
|
||||
else
|
||||
klass.send(:include, routes.url_helpers(include_path_helpers))
|
||||
klass.include(routes.url_helpers(include_path_helpers))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -144,7 +144,7 @@ module ActionDispatch
|
|||
old_controller, @controller = @controller, @controller.clone
|
||||
_routes = @routes
|
||||
|
||||
@controller.singleton_class.send(:include, _routes.url_helpers)
|
||||
@controller.singleton_class.include(_routes.url_helpers)
|
||||
@controller.view_context_class = Class.new(@controller.view_context_class) do
|
||||
include _routes.url_helpers
|
||||
end
|
||||
|
|
|
@ -29,7 +29,7 @@ module ImpressiveLibrary
|
|||
def useful_function() end
|
||||
end
|
||||
|
||||
ActionController::Base.send :include, ImpressiveLibrary
|
||||
ActionController::Base.include(ImpressiveLibrary)
|
||||
|
||||
class JustMeController < ActionController::Base
|
||||
clear_helpers
|
||||
|
@ -223,10 +223,10 @@ class HelperTest < ActiveSupport::TestCase
|
|||
# fun/pdf_helper.rb
|
||||
assert methods.include?(:foobar)
|
||||
end
|
||||
|
||||
|
||||
def test_helper_proxy_config
|
||||
AllHelpersController.config.my_var = 'smth'
|
||||
|
||||
|
||||
assert_equal 'smth', AllHelpersController.helpers.config.my_var
|
||||
end
|
||||
|
||||
|
|
|
@ -682,7 +682,7 @@ class IntegrationProcessTest < ActionDispatch::IntegrationTest
|
|||
get 'get/:action', :to => controller, :as => :get_action
|
||||
end
|
||||
|
||||
self.singleton_class.send(:include, set.url_helpers)
|
||||
self.singleton_class.include(set.url_helpers)
|
||||
|
||||
yield
|
||||
end
|
||||
|
|
|
@ -30,7 +30,7 @@ class LocalizedTemplatesTest < ActionController::TestCase
|
|||
|
||||
def test_use_fallback_locales
|
||||
I18n.locale = :"de-AT"
|
||||
I18n.backend.class.send(:include, I18n::Backend::Fallbacks)
|
||||
I18n.backend.class.include(I18n::Backend::Fallbacks)
|
||||
I18n.fallbacks[:"de-AT"] = [:de]
|
||||
|
||||
get :hello_world
|
||||
|
|
|
@ -1184,7 +1184,7 @@ class ResourcesTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
@controller = "#{options[:options][:controller].camelize}Controller".constantize.new
|
||||
@controller.singleton_class.send(:include, @routes.url_helpers)
|
||||
@controller.singleton_class.include(@routes.url_helpers)
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
get :index, params: options[:options]
|
||||
|
@ -1254,7 +1254,7 @@ class ResourcesTest < ActionController::TestCase
|
|||
def assert_singleton_named_routes_for(singleton_name, options = {})
|
||||
(options[:options] ||= {})[:controller] ||= singleton_name.to_s.pluralize
|
||||
@controller = "#{options[:options][:controller].camelize}Controller".constantize.new
|
||||
@controller.singleton_class.send(:include, @routes.url_helpers)
|
||||
@controller.singleton_class.include(@routes.url_helpers)
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
get :show, params: options[:options]
|
||||
|
|
|
@ -38,7 +38,7 @@ module ActionView
|
|||
|
||||
initializer "action_view.setup_action_pack" do |app|
|
||||
ActiveSupport.on_load(:action_controller) do
|
||||
ActionView::RoutingUrlFor.send(:include, ActionDispatch::Routing::UrlFor)
|
||||
ActionView::RoutingUrlFor.include(ActionDispatch::Routing::UrlFor)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -204,7 +204,7 @@ module ActionView
|
|||
def view
|
||||
@view ||= begin
|
||||
view = @controller.view_context
|
||||
view.singleton_class.send :include, _helpers
|
||||
view.singleton_class.include(_helpers)
|
||||
view.extend(Locals)
|
||||
view.rendered_views = self.rendered_views
|
||||
view.output_buffer = self.output_buffer
|
||||
|
|
|
@ -268,7 +268,7 @@ class Rack::TestCase < ActionDispatch::IntegrationTest
|
|||
end
|
||||
end
|
||||
|
||||
ActionView::RoutingUrlFor.send(:include, ActionDispatch::Routing::UrlFor)
|
||||
ActionView::RoutingUrlFor.include(ActionDispatch::Routing::UrlFor)
|
||||
|
||||
module ActionController
|
||||
class Base
|
||||
|
|
|
@ -4,7 +4,7 @@ require 'fixtures/project'
|
|||
require 'active_support/log_subscriber/test_helper'
|
||||
require 'action_controller/log_subscriber'
|
||||
|
||||
ActionController::Base.send :include, ActiveRecord::Railties::ControllerRuntime
|
||||
ActionController::Base.include(ActiveRecord::Railties::ControllerRuntime)
|
||||
|
||||
class ControllerRuntimeLogSubscriberTest < ActionController::TestCase
|
||||
class LogSubscriberController < ActionController::Base
|
||||
|
|
|
@ -20,7 +20,7 @@ require 'rails/test_help'
|
|||
Rails.backtrace_cleaner.remove_silencers!
|
||||
|
||||
require_relative 'test_case_helpers'
|
||||
ActiveSupport::TestCase.send(:include, TestCaseHelpers)
|
||||
ActiveSupport::TestCase.include(TestCaseHelpers)
|
||||
|
||||
JobsManager.current_manager.start_workers
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ module ActiveSupport
|
|||
return false
|
||||
else
|
||||
return false if base < self
|
||||
@_dependencies.each { |dep| base.send(:include, dep) }
|
||||
@_dependencies.each { |dep| base.include(dep) }
|
||||
super
|
||||
base.extend const_get(:ClassMethods) if const_defined?(:ClassMethods)
|
||||
base.class_eval(&@_included_block) if instance_variable_defined?(:@_included_block)
|
||||
|
|
|
@ -68,7 +68,7 @@ module I18n
|
|||
end
|
||||
|
||||
def self.include_fallbacks_module
|
||||
I18n.backend.class.send(:include, I18n::Backend::Fallbacks)
|
||||
I18n.backend.class.include(I18n::Backend::Fallbacks)
|
||||
end
|
||||
|
||||
def self.init_fallbacks(fallbacks)
|
||||
|
|
|
@ -75,5 +75,5 @@ module LibXML #:nodoc:
|
|||
end
|
||||
end
|
||||
|
||||
LibXML::XML::Document.send(:include, LibXML::Conversions::Document)
|
||||
LibXML::XML::Node.send(:include, LibXML::Conversions::Node)
|
||||
LibXML::XML::Document.include(LibXML::Conversions::Document)
|
||||
LibXML::XML::Node.include(LibXML::Conversions::Node)
|
||||
|
|
|
@ -77,7 +77,7 @@ module ActiveSupport
|
|||
end
|
||||
end
|
||||
|
||||
Nokogiri::XML::Document.send(:include, Conversions::Document)
|
||||
Nokogiri::XML::Node.send(:include, Conversions::Node)
|
||||
Nokogiri::XML::Document.include(Conversions::Document)
|
||||
Nokogiri::XML::Node.include(Conversions::Node)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -59,24 +59,24 @@ class ConcernTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_module_is_included_normally
|
||||
@klass.send(:include, Baz)
|
||||
@klass.include(Baz)
|
||||
assert_equal "baz", @klass.new.baz
|
||||
assert @klass.included_modules.include?(ConcernTest::Baz)
|
||||
end
|
||||
|
||||
def test_class_methods_are_extended
|
||||
@klass.send(:include, Baz)
|
||||
@klass.include(Baz)
|
||||
assert_equal "baz", @klass.baz
|
||||
assert_equal ConcernTest::Baz::ClassMethods, (class << @klass; self.included_modules; end)[0]
|
||||
end
|
||||
|
||||
def test_included_block_is_ran
|
||||
@klass.send(:include, Baz)
|
||||
@klass.include(Baz)
|
||||
assert_equal true, @klass.included_ran
|
||||
end
|
||||
|
||||
def test_modules_dependencies_are_met
|
||||
@klass.send(:include, Bar)
|
||||
@klass.include(Bar)
|
||||
assert_equal "bar", @klass.new.bar
|
||||
assert_equal "bar+baz", @klass.new.baz
|
||||
assert_equal "bar's baz + baz", @klass.baz
|
||||
|
@ -84,7 +84,7 @@ class ConcernTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_dependencies_with_multiple_modules
|
||||
@klass.send(:include, Foo)
|
||||
@klass.include(Foo)
|
||||
assert_equal [ConcernTest::Foo, ConcernTest::Bar, ConcernTest::Baz], @klass.included_modules[0..2]
|
||||
end
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ module Rails
|
|||
end
|
||||
|
||||
if defined?(console::ExtendCommandBundle)
|
||||
console::ExtendCommandBundle.send :include, Rails::ConsoleMethods
|
||||
console::ExtendCommandBundle.include(Rails::ConsoleMethods)
|
||||
end
|
||||
console.start
|
||||
end
|
||||
|
|
|
@ -484,7 +484,7 @@ module Rails
|
|||
helpers = Module.new
|
||||
all = ActionController::Base.all_helpers_from_path(helpers_paths)
|
||||
ActionController::Base.modules_for_helpers(all).each do |mod|
|
||||
helpers.send(:include, mod)
|
||||
helpers.include(mod)
|
||||
end
|
||||
helpers
|
||||
end
|
||||
|
|
|
@ -127,7 +127,7 @@ module Rails
|
|||
def builder
|
||||
@builder ||= begin
|
||||
builder_class = get_builder_class
|
||||
builder_class.send(:include, ActionMethods)
|
||||
builder_class.include(ActionMethods)
|
||||
builder_class.new(self)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ module Rails
|
|||
module ResourceHelpers # :nodoc:
|
||||
|
||||
def self.included(base) #:nodoc:
|
||||
base.send :include, Rails::Generators::ModelHelpers
|
||||
base.include(Rails::Generators::ModelHelpers)
|
||||
base.class_option :model_name, type: :string, desc: "ModelName to be used"
|
||||
end
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ class InfoControllerTest < ActionController::TestCase
|
|||
end
|
||||
@routes = Rails.application.routes
|
||||
|
||||
Rails::InfoController.send(:include, @routes.url_helpers)
|
||||
Rails::InfoController.include(@routes.url_helpers)
|
||||
|
||||
@request.env["REMOTE_ADDR"] = "127.0.0.1"
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue