mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge branch 'master' into mdluo-master
* master: Move required error message and changelog to Active Record Use public Module#include, in favor of https://bugs.ruby-lang.org/issues/8846 Use Module#include instead of send :include, since now is a public method [ci skip] ✂️ warning from controller renderer test Conflicts: activerecord/CHANGELOG.md
This commit is contained in:
commit
aa8ade5811
29 changed files with 45 additions and 45 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
|
||||
|
|
|
@ -65,10 +65,10 @@ class RendererTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
test 'same defaults from the same controller' do
|
||||
defaults = ->(controller) { controller.renderer.defaults }
|
||||
renderer_defaults = ->(controller) { controller.renderer.defaults }
|
||||
|
||||
assert defaults[AccountsController].equal? defaults[AccountsController]
|
||||
assert_not defaults[AccountsController].equal? defaults[CommentsController]
|
||||
assert renderer_defaults[AccountsController].equal? renderer_defaults[AccountsController]
|
||||
assert_not renderer_defaults[AccountsController].equal? renderer_defaults[CommentsController]
|
||||
end
|
||||
|
||||
test 'rendering with different formats' do
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -1,8 +1,3 @@
|
|||
* Change the default error message from `can't be blank` to `must exist` for
|
||||
the presence validator of the `:required` option on `belongs_to`/`has_one` associations.
|
||||
|
||||
*Henrik Nygren*
|
||||
|
||||
* Assigning an unknown attribute key to an `ActiveModel` instance during initialization
|
||||
will now raise `ActiveModel::AttributeAssignment::UnknownAttributeError` instead of
|
||||
`NoMethodError`
|
||||
|
|
|
@ -14,10 +14,9 @@ en:
|
|||
empty: "can't be empty"
|
||||
blank: "can't be blank"
|
||||
present: "must be blank"
|
||||
required: "must exist"
|
||||
too_long:
|
||||
one: "is too long (maximum is 1 character)"
|
||||
other: "is too long (maximum is %{count} characters)"
|
||||
other: "is too long (maximum is %{count} characters)"
|
||||
too_short:
|
||||
one: "is too short (minimum is 1 character)"
|
||||
other: "is too short (minimum is %{count} characters)"
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
*Sammy Larbi*
|
||||
|
||||
* Change the default error message from `can't be blank` to `must exist` for
|
||||
the presence validator of the `:required` option on `belongs_to`/`has_one` associations.
|
||||
|
||||
*Henrik Nygren*
|
||||
|
||||
* Fixed ActiveRecord::Relation#group method when argument is SQL reserved key word:
|
||||
|
||||
Example:
|
||||
|
|
|
@ -132,7 +132,7 @@ module ActiveRecord
|
|||
# Digest::SHA2.hexdigest(File.read(Rails.root.join('test/fixtures', path)))
|
||||
# end
|
||||
# end
|
||||
# ActiveRecord::FixtureSet.context_class.send :include, FixtureFileHelpers
|
||||
# ActiveRecord::FixtureSet.context_class.include FixtureFileHelpers
|
||||
#
|
||||
# - use the helper method in a fixture
|
||||
# photo:
|
||||
|
@ -522,7 +522,7 @@ module ActiveRecord
|
|||
update_all_loaded_fixtures fixtures_map
|
||||
|
||||
connection.transaction(:requires_new => true) do
|
||||
deleted_tables = Set.new
|
||||
deleted_tables = Set.new
|
||||
fixture_sets.each do |fs|
|
||||
conn = fs.model_class.respond_to?(:connection) ? fs.model_class.connection : connection
|
||||
table_rows = fs.table_rows
|
||||
|
|
|
@ -7,6 +7,7 @@ en:
|
|||
# Default error messages
|
||||
errors:
|
||||
messages:
|
||||
required: "must exist"
|
||||
taken: "has already been taken"
|
||||
|
||||
# Active Record models configuration
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -534,7 +534,7 @@ module FixtureFileHelpers
|
|||
Digest::SHA2.hexdigest(File.read(Rails.root.join('test/fixtures', path)))
|
||||
end
|
||||
end
|
||||
ActiveRecord::FixtureSet.context_class.send :include, FixtureFileHelpers
|
||||
ActiveRecord::FixtureSet.context_class.include FixtureFileHelpers
|
||||
```
|
||||
|
||||
### I18n enforcing available locales
|
||||
|
|
|
@ -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