aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/numeric_ext_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Deprecate "active_support/core_ext/numeric/inquiry"bogdanvlviv2018-03-021-80/+3
| | | | | | Numeric#positive? and Numeric#negative? was added to Ruby since 2.3, see https://github.com/ruby/ruby/blob/ruby_2_3/NEWS Rails 6 requires Ruby 2.4.1+ since https://github.com/rails/rails/pull/32034
* Enable `Layout/LeadingCommentSpace` to not allow cosmetic changes in the futureRyuta Kamizono2017-12-141-6/+6
| | | | Follow up of #31432.
* [Active Support] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-111-0/+1
|
* Use frozen-string-literal in ActiveSupportKir Shatrov2017-07-091-0/+1
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* Allocation free Integer#to_sJean Boussier2017-01-191-0/+4
|
* Fix inconsistent results when parsing large durations and constructing ↵Andrey Novikov2017-01-091-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | durations from code ActiveSupport::Duration.parse('P3Y') == 3.years # It should be true Duration parsing made independent from any moment of time: Fixed length in seconds is assigned to each duration part during parsing. Changed duration of months and years in seconds to more accurate and logical: 1. The value of 365.2425 days in Gregorian year is more accurate as it accounts for every 400th non-leap year. 2. Month's length is bound to year's duration, which makes sensible comparisons like `12.months == 1.year` to be `true` and nonsensical ones like `30.days == 1.month` to be `false`. Calculations on times and dates with durations shouldn't be affected as duration's numeric value isn't used in calculations, only parts are used. Methods on `Numeric` like `2.days` now use these predefined durations to avoid duplicating of duration constants through the codebase and eliminate creation of intermediate durations.
* Merge pull request #27035 from rails/remove-active-support-deprecationsAndrew White2016-11-141-21/+0
|\ | | | | Remove Active Support deprecations
| * Remove deprecated method Numeric#to_formatted_sAndrew White2016-11-141-6/+0
| |
| * Remove deprecated :prefix optionAndrew White2016-11-131-15/+0
| |
* | Remove warning from access to Bignum class, 2**64 is already a known bignum ↵Vipul A M2016-11-131-1/+0
|/ | | | value. See also http://patshaughnessy.net/2014/1/9/how-big-is-a-bignum for smallest bignum value
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-32/+32
|
* Add three new rubocop rulesRafael Mendonça França2016-08-161-6/+6
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* Add `Style/EmptyLines` in `.rubocop.yml` and remove extra empty linesRyuta Kamizono2016-08-071-2/+0
|
* modernizes hash syntax in activesupportXavier Noria2016-08-061-147/+147
|
* applies new string literal convention in activesupport/testXavier Noria2016-08-061-117/+117
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Support for unified Integer class in Ruby 2.4+Jeremy Daer2016-05-181-7/+0
| | | | | | | | Ruby 2.4 unifies Fixnum and Bignum into Integer: https://bugs.ruby-lang.org/issues/12005 * Forward compat with new unified Integer class in Ruby 2.4+. * Backward compat with separate Fixnum/Bignum in Ruby 2.2 & 2.3. * Drops needless Fixnum distinction in docs, preferring Integer.
* Fix - to_s(:db) on Numeric rangeAkshay Vishnoi2015-12-291-0/+20
|
* Merge pull request #22824 from maclover7/add-numericwithformat-testsYves Senn2015-12-291-0/+6
|\ | | | | Add test coverage for ActiveSupport::NumericWithFormat#to_formatted_s
| * Add test coverage for ActiveSupport::NumericWithFormat#to_formatted_sJon Moss2015-12-281-0/+6
| |
* | Add support for Petabyte and Exabyte in number to human sizeAkshay Vishnoi2015-12-221-1/+13
|/
* Assert that the `:prefix` option of `number_to_human_size` is deprecatedRoque Pinel2015-08-121-8/+10
|
* Only define #positive? and #negative? on Ruby 2.2Rafael Mendonça França2015-05-191-6/+78
| | | | | | | The feature was accepted and added to Ruby 2.3+ so we don't need to define it again. See https://bugs.ruby-lang.org/issues/11151
* Merge pull request #20143 from vngrs/move_integer_positive_negative_to_numericRafael Mendonça França2015-05-191-0/+12
|\ | | | | | | Move Integer#positive? and Integer#negative? query methods to Numeric
| * Move Integer#positive? and Integer#negative? query methods to Numeric classMehmet Emin İNAÇ2015-05-131-0/+12
|/ | | | By this way Integer, Rational, Float, Fixnum, Bignum classes have the same behaviour
* Extract out with_env_tz helper method.Zuhao Wan2014-06-181-8/+0
| | | | | It’s used at so many places that extracting it out into a helper file is worth doing.
* :scissors: removed deprecated `Numeric#ago` and friendsGodfrey Chan2014-05-301-43/+1
| | | | | | | | | | | | | | Replacements: 5.ago => 5.seconds.ago 5.until => 5.seconds.until 5.since => 5.seconds.since 5.from_now => 5.seconds.from_now The removed tests does not affect coverage – we have equivalent test cases in the tests for `AS::Duration`. See #12389 for the history and rationale behind this.
* Deprecated Numeric#{ago,until,since,from_now}Godfrey Chan2013-11-261-27/+22
| | | | | | | | | | | | | | | | | | | | | | The user is expected to explicitly convert the value into an AS::Duration, i.e. `5.ago` => `5.seconds.ago` This will help to catch subtle bugs like: def recent?(days = 3) self.created_at >= days.ago end The above code would check if the model is created within the last 3 **seconds**. In the future, `Numeric#{ago,until,since,from_now}` should be removed completely, or throw some sort of errors to indicate there are no implicit conversion from `Numeric` to `AS::Duration`. Also fixed & refactor the test cases for Numeric#{ago,since} and AS::Duration#{ago,since}. The original test case had the assertion flipped and the purpose of the test wasn't very clear.
* Added Numeric#in_milliseconds, like 1.hour.in_milliseconds, so we can feed ↵David Heinemeier Hansson2013-11-021-0/+4
| | | | them to JavaScript functions like getTime().
* Fix some typo in method names, variablesVipul A M2013-05-261-1/+1
|
* Squashed commit of the following:Aaron Patterson2013-05-031-54/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | commit 2683de5da85135e8d9fe48593ff6167db9d64b18 Author: Aaron Patterson <aaron.patterson@gmail.com> Date: Fri May 3 11:29:20 2013 -0700 cannot support infinite ranges right now commit cebb6acef2c3957f975f6db4afd849e535126253 Author: Aaron Patterson <aaron.patterson@gmail.com> Date: Fri May 3 11:26:12 2013 -0700 reverting infinity comparison commit 385f7e6b4efd1bf9b89e8d607fcb13e5b03737ea Author: Aaron Patterson <aaron.patterson@gmail.com> Date: Fri May 3 11:23:28 2013 -0700 Revert "Added ability to compare date/time with infinity" This reverts commit 38f28dca3aa16efd6cc3af6453f2e6b9e9655ec1. Conflicts: activesupport/CHANGELOG.md activesupport/lib/active_support/core_ext/numeric/infinite_comparable.rb activesupport/test/core_ext/date_ext_test.rb activesupport/test/core_ext/date_time_ext_test.rb activesupport/test/core_ext/numeric_ext_test.rb activesupport/test/core_ext/time_ext_test.rb activesupport/test/core_ext/time_with_zone_test.rb commit 0d799a188dc12b18267fc8421675729917610047 Author: Aaron Patterson <aaron.patterson@gmail.com> Date: Fri May 3 11:18:53 2013 -0700 Revert "Refactor infinite comparable definition a bit" This reverts commit dd3360e05e4909f2f0c74a624cccc2def688f828. commit 42dec90e49745bbfae546f0560b8783f6b48b074 Author: Aaron Patterson <aaron.patterson@gmail.com> Date: Fri May 3 11:18:47 2013 -0700 Revert "Require 'active_support/core_ext/module/aliasing' in the infinite_comparable module" This reverts commit 7003e71c13c53ec3d34250560fbf80b8381df693.
* refactor test to drop unnecessary hash creation, test directly insteadVipul A M2013-03-171-16/+10
|
* Remove assert_nothing_raisedRafael Mendonça França2013-01-031-50/+40
|
* Added ability to compare date/time with infinitybUg2013-01-041-0/+64
| | | | | | | | | | | | | | | | | Date, DateTime, Time and TimeWithZone can now be compared to infinity, so it's now possible to create ranges with one infinite bound and date/time object as another bound. Ex.: @range = Range.new(Date.today, Float::INFINITY) Also it's possible to check inclusion of date/time in range with conversion. Ex.: @range.include?(Time.now + 1.year) # => true @range.include?(DateTime.now + 1.year) # => true Ability to create date/time ranges with infinite bound is required for handling postgresql range types.
* Moving NumberHelpers from ActionView to ActiveSupportAndrew Mutz2012-05-271-0/+261
|
* use AS::TestCase as the base classAaron Patterson2012-01-051-3/+3
|
* updated Time, Date and DateTime current methods in AS to use Time.zone and ↵Josh Kalderimis2011-02-281-5/+5
| | | | | | not Time.zone_default. [#6410 state:committed]
* Use `Time.current` to maintain consistency with AS::DurationPrem Sichanugrist2010-09-191-0/+38
| | | | | | | | | | In [32b82e4c6f5523cdf5ee78c3022c50b46e018351], the committer has switch methods in AS::Duration to use `Time.current` to return the correct duration based on the `Time.default_zone` instead of using `Time.now`. [#5607 state:committed] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Deletes trailing whitespaces (over text files only find * -type f -exec sed ↵Santiago Pastorino2010-08-141-12/+12
| | | | 's/[ \t]*$//' -i {} \;)
* Remove 'core' fluff. Hookable ActiveSupport.load_all!Jeremy Kemper2009-05-201-1/+1
|
* Fix dependencies revealed by testing in isolationJeremy Kemper2009-04-221-2/+3
|
* Explicit test dependenciesJeremy Kemper2009-03-281-0/+2
|
* Move Numeric#to_utc_offset_s to TimeZone.seconds_to_utc_offsetJeremy Kemper2009-03-231-15/+0
|
* Fix Numeric time tests broken by DST change by anchoring them to fixed times ↵Geoff Buesing2008-03-111-2/+2
| | | | | | instead of Time.now. Anchor TimeZone#now DST test to time specified with Time.at instead of Time.local to work around platform differences with Time.local and DST representation git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9009 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Refactor number-to-HH:MM-string conversion logic from ↵Geoff Buesing2008-01-121-0/+15
| | | | | | TimeZone#formatted_offset to reusable Numeric#to_utc_offset_s method git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8635 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* require abstract_unit directly since test is in load pathJeremy Kemper2008-01-051-1/+1
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8563 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Ruby 1.9 compat: define Duration#== [chuyeow]Jeremy Kemper2007-12-151-1/+0
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8399 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Mark another Duration test failing with Ruby 1.9Jeremy Kemper2007-09-271-0/+1
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7653 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* More tests (closes #7066) [sethladd]David Heinemeier Hansson2007-09-221-0/+15
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7586 5ecf4fe2-1ee6-0310-87b1-e25e094e27de