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:
commit
b1e40cff80
3 changed files with 19 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue