diff --git a/activerecord/lib/active_record/relation/delegation.rb b/activerecord/lib/active_record/relation/delegation.rb index fcecc8657e..7b4234bc77 100644 --- a/activerecord/lib/active_record/relation/delegation.rb +++ b/activerecord/lib/active_record/relation/delegation.rb @@ -87,7 +87,7 @@ module ActiveRecord delegate :to_xml, :encode_with, :length, :each, :join, :[], :&, :|, :+, :-, :sample, :reverse, :rotate, :compact, :in_groups, :in_groups_of, - :to_sentence, :to_fs, :as_json, + :to_sentence, :to_fs, :to_formatted_s, :as_json, :shuffle, :split, :slice, :index, :rindex, to: :records delegate :primary_key, :connection, to: :klass diff --git a/activerecord/test/cases/relation/delegation_test.rb b/activerecord/test/cases/relation/delegation_test.rb index 2d7a3e3955..f8b904dc2e 100644 --- a/activerecord/test/cases/relation/delegation_test.rb +++ b/activerecord/test/cases/relation/delegation_test.rb @@ -13,7 +13,7 @@ module ActiveRecord :map, :none?, :one?, :partition, :reject, :reverse, :rotate, :sample, :second, :sort, :sort_by, :slice, :third, :index, :rindex, :to_ary, :to_set, :to_xml, :to_yaml, :join, - :in_groups, :in_groups_of, :to_sentence, :to_fs, :as_json + :in_groups, :in_groups_of, :to_sentence, :to_formatted_s, :to_fs, :as_json ] ARRAY_DELEGATES.each do |method| diff --git a/activesupport/lib/active_support/core_ext/date/conversions.rb b/activesupport/lib/active_support/core_ext/date/conversions.rb index 56a582fcec..b75badddfb 100644 --- a/activesupport/lib/active_support/core_ext/date/conversions.rb +++ b/activesupport/lib/active_support/core_ext/date/conversions.rb @@ -26,8 +26,8 @@ class Date # # date = Date.new(2007, 11, 10) # => Sat, 10 Nov 2007 # - # date.to_fs(:db) # => "2007-11-10" # date.to_fs(:db) # => "2007-11-10" + # date.to_formatted_s(:db) # => "2007-11-10" # # date.to_fs(:short) # => "10 Nov" # date.to_fs(:number) # => "20071110" diff --git a/activesupport/lib/active_support/core_ext/date_time/conversions.rb b/activesupport/lib/active_support/core_ext/date_time/conversions.rb index da9b16f0e2..be1c472c8e 100644 --- a/activesupport/lib/active_support/core_ext/date_time/conversions.rb +++ b/activesupport/lib/active_support/core_ext/date_time/conversions.rb @@ -15,7 +15,7 @@ class DateTime # datetime = DateTime.civil(2007, 12, 4, 0, 0, 0, 0) # => Tue, 04 Dec 2007 00:00:00 +0000 # # datetime.to_fs(:db) # => "2007-12-04 00:00:00" - # datetime.to_fs(:db) # => "2007-12-04 00:00:00" + # datetime.to_formatted_s(:db) # => "2007-12-04 00:00:00" # datetime.to_fs(:number) # => "20071204000000" # datetime.to_fs(:short) # => "04 Dec 00:00" # datetime.to_fs(:long) # => "December 04, 2007 00:00" diff --git a/activesupport/lib/active_support/core_ext/time/conversions.rb b/activesupport/lib/active_support/core_ext/time/conversions.rb index 376939b27d..aeb8e142e1 100644 --- a/activesupport/lib/active_support/core_ext/time/conversions.rb +++ b/activesupport/lib/active_support/core_ext/time/conversions.rb @@ -31,8 +31,8 @@ class Time # # time = Time.now # => 2007-01-18 06:10:17 -06:00 # - # time.to_fs(:time) # => "06:10" # time.to_fs(:time) # => "06:10" + # time.to_formatted_s(:time) # => "06:10" # # time.to_fs(:db) # => "2007-01-18 06:10:17" # time.to_fs(:number) # => "20070118061017" diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb index 601deac55b..e967bf0ea0 100644 --- a/activesupport/lib/active_support/time_with_zone.rb +++ b/activesupport/lib/active_support/time_with_zone.rb @@ -33,7 +33,7 @@ module ActiveSupport # t.dst? # => true # t.utc_offset # => -14400 # t.zone # => "EDT" - # t.to_fs(:rfc822) # => "Sun, 18 May 2008 13:27:25 -0400" + # t.to_fs(:rfc822) # => "Sun, 18 May 2008 13:27:25 -0400" # t + 1.day # => Mon, 19 May 2008 13:27:25.031505668 EDT -04:00 # t.beginning_of_year # => Tue, 01 Jan 2008 00:00:00.000000000 EST -05:00 # t > Time.utc(1999) # => true diff --git a/activesupport/test/core_ext/array/conversions_test.rb b/activesupport/test/core_ext/array/conversions_test.rb index a117c653d4..e455773146 100644 --- a/activesupport/test/core_ext/array/conversions_test.rb +++ b/activesupport/test/core_ext/array/conversions_test.rb @@ -116,8 +116,8 @@ class ToSTest < ActiveSupport::TestCase assert_equal "null", [].to_fs(:db) assert_equal "1,2,3", collection.to_fs(:db) - assert_equal "null", [].to_fs(:db) - assert_equal "4,5,6", collection.to_fs(:db) + assert_equal "null", [].to_formatted_s(:db) + assert_equal "4,5,6", collection.to_formatted_s(:db) end end diff --git a/activesupport/test/core_ext/date_ext_test.rb b/activesupport/test/core_ext/date_ext_test.rb index 86381ba248..e0e7713a54 100644 --- a/activesupport/test/core_ext/date_ext_test.rb +++ b/activesupport/test/core_ext/date_ext_test.rb @@ -88,7 +88,7 @@ class DateExtCalculationsTest < ActiveSupport::TestCase assert_equal "2005-02-21", date.to_fs(:inspect) assert_equal "21 Feb 2005", date.to_fs(:rfc822) assert_equal "2005-02-21", date.to_fs(:iso8601) - assert_equal "21 Feb", date.to_fs(:short) + assert_equal "21 Feb", date.to_formatted_s(:short) end def test_to_fs_with_single_digit_day diff --git a/activesupport/test/core_ext/date_time_ext_test.rb b/activesupport/test/core_ext/date_time_ext_test.rb index a6af675741..a7e9ea3d2a 100644 --- a/activesupport/test/core_ext/date_time_ext_test.rb +++ b/activesupport/test/core_ext/date_time_ext_test.rb @@ -72,7 +72,7 @@ class DateTimeExtCalculationsTest < ActiveSupport::TestCase assert_equal "2009-02-05T14:30:05+00:00", DateTime.civil(2009, 2, 5, 14, 30, 5).to_fs(:iso8601) end - assert_equal "2005-02-21 14:30:00", datetime.to_fs(:db) + assert_equal "2005-02-21 14:30:00", datetime.to_formatted_s(:db) end def test_readable_inspect diff --git a/activesupport/test/core_ext/numeric_ext_test.rb b/activesupport/test/core_ext/numeric_ext_test.rb index e0995669e5..e5eee2d3e9 100644 --- a/activesupport/test/core_ext/numeric_ext_test.rb +++ b/activesupport/test/core_ext/numeric_ext_test.rb @@ -162,7 +162,7 @@ class NumericExtFormattingTest < ActiveSupport::TestCase assert_equal("555-1234", 5551234.to_s(:phone)) end assert_equal("555-1234", 5551234.to_fs(:phone)) - assert_equal("555-1234", 5551234.to_fs(:phone)) + assert_equal("555-1234", 5551234.to_formatted_s(:phone)) assert_equal("800-555-1212", 8005551212.to_fs(:phone)) assert_equal("(800) 555-1212", 8005551212.to_fs(:phone, area_code: true)) assert_equal("800 555 1212", 8005551212.to_fs(:phone, delimiter: " ")) @@ -180,7 +180,7 @@ class NumericExtFormattingTest < ActiveSupport::TestCase assert_equal("$1,234,567,890.50", 1234567890.50.to_s(:currency)) end assert_equal("$1,234,567,890.50", 1234567890.50.to_fs(:currency)) - assert_equal("$1,234,567,890.50", 1234567890.50.to_fs(:currency)) + assert_equal("$1,234,567,890.50", 1234567890.50.to_formatted_s(:currency)) assert_equal("$1,234,567,890.51", 1234567890.506.to_fs(:currency)) assert_equal("-$1,234,567,890.50", -1234567890.50.to_fs(:currency)) assert_equal("-$ 1,234,567,890.50", -1234567890.50.to_fs(:currency, format: "%u %n")) @@ -196,7 +196,7 @@ class NumericExtFormattingTest < ActiveSupport::TestCase assert_equal("-111.235", -111.2346.to_s(:rounded)) end assert_equal("-111.235", -111.2346.to_fs(:rounded)) - assert_equal("-111.235", -111.2346.to_fs(:rounded)) + assert_equal("-111.235", -111.2346.to_formatted_s(:rounded)) assert_equal("111.235", 111.2346.to_fs(:rounded)) assert_equal("31.83", 31.825.to_fs(:rounded, precision: 2)) assert_equal("31.82", 31.825.to_fs(:rounded, precision: 2, round_mode: :down)) @@ -259,7 +259,7 @@ class NumericExtFormattingTest < ActiveSupport::TestCase assert_equal("100.000%", 100.to_s(:percentage)) end assert_equal("100.000%", 100.to_fs(:percentage)) - assert_equal("100.000%", 100.to_fs(:percentage)) + assert_equal("100.000%", 100.to_formatted_s(:percentage)) assert_equal("100%", 100.to_fs(:percentage, precision: 0)) assert_equal("302.06%", 302.0574.to_fs(:percentage, precision: 2)) assert_equal("302.05%", 302.0574.to_fs(:percentage, precision: 2, round_mode: :down)) @@ -273,7 +273,7 @@ class NumericExtFormattingTest < ActiveSupport::TestCase assert_equal("12,345,678", 12345678.to_s(:delimited)) end assert_equal("12,345,678", 12345678.to_fs(:delimited)) - assert_equal("12,345,678", 12345678.to_fs(:delimited)) + assert_equal("12,345,678", 12345678.to_formatted_s(:delimited)) assert_equal("0", 0.to_fs(:delimited)) assert_equal("123", 123.to_fs(:delimited)) assert_equal("123,456", 123456.to_fs(:delimited)) @@ -348,7 +348,7 @@ class NumericExtFormattingTest < ActiveSupport::TestCase assert_equal "-123", -123.to_s(:human) end assert_equal "-123", -123.to_fs(:human) - assert_equal "-123", -123.to_fs(:human) + assert_equal "-123", -123.to_formatted_s(:human) assert_equal "-0.5", -0.5.to_fs(:human) assert_equal "0", 0.to_fs(:human) assert_equal "0.5", 0.5.to_fs(:human) @@ -420,7 +420,7 @@ class NumericExtFormattingTest < ActiveSupport::TestCase assert_equal "123", 123.to_s(:invalid) end assert_equal "123", 123.to_fs(:invalid) - assert_equal "123", 123.to_fs(:invalid) + assert_equal "123", 123.to_formatted_s(:invalid) assert_equal "2.5", 2.5.to_fs(:invalid) assert_equal "100000000000000000000", (100**10).to_fs(:invalid) assert_equal "1000010.0", BigDecimal("1000010").to_fs(:invalid) @@ -429,7 +429,7 @@ class NumericExtFormattingTest < ActiveSupport::TestCase def test_default_to_fs assert_equal "123", 123.to_s assert_equal "123", 123.to_fs - assert_equal "123", 123.to_fs + assert_equal "123", 123.to_formatted_s assert_equal "1111011", 123.to_s(2) assert_equal "1111011", 123.to_fs(2) diff --git a/activesupport/test/core_ext/range_ext_test.rb b/activesupport/test/core_ext/range_ext_test.rb index a7ed127a82..cd6ed6c475 100644 --- a/activesupport/test/core_ext/range_ext_test.rb +++ b/activesupport/test/core_ext/range_ext_test.rb @@ -9,7 +9,7 @@ class RangeTest < ActiveSupport::TestCase def test_to_fs_from_dates date_range = Date.new(2005, 12, 10)..Date.new(2005, 12, 12) assert_equal "BETWEEN '2005-12-10' AND '2005-12-12'", date_range.to_fs(:db) - assert_equal "BETWEEN '2005-12-10' AND '2005-12-12'", date_range.to_fs(:db) + assert_equal "BETWEEN '2005-12-10' AND '2005-12-12'", date_range.to_formatted_s(:db) end def test_to_fs_from_times diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb index 37b27ee0f7..f8cc4561b5 100644 --- a/activesupport/test/core_ext/time_ext_test.rb +++ b/activesupport/test/core_ext/time_ext_test.rb @@ -667,7 +667,7 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase assert_equal "2008-06-09 04:05:01.000000000 -0500", Time.local(2008, 6, 9, 4, 5, 1).to_fs(:inspect) end - assert_equal "2005-02-21 17:44:30", time.to_fs(:db) + assert_equal "2005-02-21 17:44:30", time.to_formatted_s(:db) end def test_to_s_custom_date_format diff --git a/activesupport/test/core_ext/time_with_zone_test.rb b/activesupport/test/core_ext/time_with_zone_test.rb index 6ea2522699..a14a89a2d7 100644 --- a/activesupport/test/core_ext/time_with_zone_test.rb +++ b/activesupport/test/core_ext/time_with_zone_test.rb @@ -139,7 +139,7 @@ class TimeWithZoneTest < ActiveSupport::TestCase def test_to_fs_db assert_equal "2000-01-01 00:00:00", @twz.to_fs(:db) - assert_equal "2000-01-01 00:00:00", @twz.to_fs(:db) + assert_equal "2000-01-01 00:00:00", @twz.to_formatted_s(:db) end def test_to_fs_inspect