diff options
author | Konstantinos Rousis <rousisk@gmail.com> | 2015-10-22 12:43:41 +0200 |
---|---|---|
committer | Konstantinos Rousis <rousisk@gmail.com> | 2015-10-22 12:44:03 +0200 |
commit | 0d2ce9d72396f449a15a3f914248cbc8cc8a4a4f (patch) | |
tree | 3e32cb83aab10ff7b89d88e74de9995b41555641 | |
parent | f66b68173a11d0ef8f4bb6253386c15d031017ba (diff) | |
download | rails-0d2ce9d72396f449a15a3f914248cbc8cc8a4a4f.tar.gz rails-0d2ce9d72396f449a15a3f914248cbc8cc8a4a4f.tar.bz2 rails-0d2ce9d72396f449a15a3f914248cbc8cc8a4a4f.zip |
Change Integer#year to return a Fixnum instead of a Float to improve consistency
-rw-r--r-- | actionpack/test/controller/render_test.rb | 4 | ||||
-rw-r--r-- | activesupport/CHANGELOG.md | 16 | ||||
-rw-r--r-- | activesupport/lib/active_support/core_ext/integer/time.rb | 2 |
3 files changed, 19 insertions, 3 deletions
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index 82c7ebf568..256ebf6a07 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -629,13 +629,13 @@ class HttpCacheForeverTest < ActionController::TestCase def test_cache_with_public get :cache_me_forever, params: {public: true} - assert_equal "max-age=#{100.years.to_i}, public", @response.headers["Cache-Control"] + assert_equal "max-age=#{100.years}, public", @response.headers["Cache-Control"] assert_not_nil @response.etag end def test_cache_with_private get :cache_me_forever - assert_equal "max-age=#{100.years.to_i}, private", @response.headers["Cache-Control"] + assert_equal "max-age=#{100.years}, private", @response.headers["Cache-Control"] assert_not_nil @response.etag assert_response :success end diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md index fcbb3ea372..3705fc57fc 100644 --- a/activesupport/CHANGELOG.md +++ b/activesupport/CHANGELOG.md @@ -1,3 +1,19 @@ +* Change Integer#year to return a Fixnum instead of a Float to improve + consistency. + + Integer#years returned a Float while the rest of the accompanying methods + (days, weeks, months, etc.) return a Fixnum. + + Before: + + 1.year # => 31557600.0 + + After: + + 1.year # => 31557600 + + *Konstantinos Rousis* + * Handle invalid UTF-8 strings when HTML escaping Use `ActiveSupport::Multibyte::Unicode.tidy_bytes` to handle invalid UTF-8 diff --git a/activesupport/lib/active_support/core_ext/integer/time.rb b/activesupport/lib/active_support/core_ext/integer/time.rb index f0b7382ef3..87185b024f 100644 --- a/activesupport/lib/active_support/core_ext/integer/time.rb +++ b/activesupport/lib/active_support/core_ext/integer/time.rb @@ -23,7 +23,7 @@ class Integer alias :month :months def years - ActiveSupport::Duration.new(self * 365.25.days, [[:years, self]]) + ActiveSupport::Duration.new(self * 365.25.days.to_i, [[:years, self]]) end alias :year :years end |