1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #19327 from rousisk/master

Change Integer#year to return a Fixnum instead of a Float to improve consistency
This commit is contained in:
Sean Griffin 2015-10-22 07:07:27 -06:00
commit b1e40cff80
3 changed files with 19 additions and 3 deletions

View file

@ -629,13 +629,13 @@ class HttpCacheForeverTest < ActionController::TestCase
def test_cache_with_public def test_cache_with_public
get :cache_me_forever, params: {public: true} 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 assert_not_nil @response.etag
end end
def test_cache_with_private def test_cache_with_private
get :cache_me_forever 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_not_nil @response.etag
assert_response :success assert_response :success
end end

View file

@ -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 * Handle invalid UTF-8 strings when HTML escaping
Use `ActiveSupport::Multibyte::Unicode.tidy_bytes` to handle invalid UTF-8 Use `ActiveSupport::Multibyte::Unicode.tidy_bytes` to handle invalid UTF-8

View file

@ -23,7 +23,7 @@ class Integer
alias :month :months alias :month :months
def years def years
ActiveSupport::Duration.new(self * 365.25.days, [[:years, self]]) ActiveSupport::Duration.new(self * 365.25.days.to_i, [[:years, self]])
end end
alias :year :years alias :year :years
end end