提交 253ddeb3 编写于 作者: M Matthew Draper 提交者: GitHub

Merge pull request #26732 from matthewd/fixnum-warning

Fixnum and Bignum are deprecated in Ruby trunk
......@@ -34,8 +34,8 @@ class SerializationError < ArgumentError; end
module Arguments
extend self
# :nodoc:
# Calls #uniq since Integer, Fixnum, and Bignum are all the same class on Ruby 2.4+
TYPE_WHITELIST = [ NilClass, String, Integer, Fixnum, Bignum, Float, BigDecimal, TrueClass, FalseClass ].uniq
TYPE_WHITELIST = [ NilClass, String, Integer, Float, BigDecimal, TrueClass, FalseClass ]
TYPE_WHITELIST.push(Fixnum, Bignum) unless 1.class == Integer
# Serializes a set of arguments. Whitelisted types are returned
# as-is. Arrays/Hashes are serialized element by element.
......
......@@ -138,7 +138,7 @@ def test_cache_does_not_wrap_string_results_in_arrays
assert_kind_of Numeric, Task.connection.select_value("SELECT count(*) AS count_all FROM tasks")
elsif current_adapter?(:SQLite3Adapter, :Mysql2Adapter, :PostgreSQLAdapter)
# Future versions of the sqlite3 adapter will return numeric
assert_instance_of Fixnum, Task.connection.select_value("SELECT count(*) AS count_all FROM tasks")
assert_instance_of 0.class, Task.connection.select_value("SELECT count(*) AS count_all FROM tasks")
else
assert_instance_of String, Task.connection.select_value("SELECT count(*) AS count_all FROM tasks")
end
......
......@@ -134,7 +134,7 @@ def to_formatted_s(*args)
end
# Ruby 2.4+ unifies Fixnum & Bignum into Integer.
if Integer == Fixnum
if 0.class == Integer
Integer.prepend ActiveSupport::NumericWithFormat
else
Fixnum.prepend ActiveSupport::NumericWithFormat
......
......@@ -48,8 +48,8 @@ def content_type
}
# No need to map these on Ruby 2.4+
TYPE_NAMES["Fixnum"] = "integer" unless Fixnum == Integer
TYPE_NAMES["Bignum"] = "integer" unless Bignum == Integer
TYPE_NAMES["Fixnum"] = "integer" unless 0.class == Integer
TYPE_NAMES["Bignum"] = "integer" unless 0.class == Integer
end
FORMATTING = {
......
......@@ -4,11 +4,11 @@
class GroupingTest < ActiveSupport::TestCase
def setup
# In Ruby < 2.4, test we avoid Integer#/ (redefined by mathn)
Fixnum.send :private, :/ unless Fixnum == Integer
Fixnum.send :private, :/ unless 0.class == Integer
end
def teardown
Fixnum.send :public, :/ unless Fixnum == Integer
Fixnum.send :public, :/ unless 0.class == Integer
end
def test_in_groups_of_with_perfect_fit
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册