aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/numeric_ext_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Fix Time#advance bug when trying to advance a year from leap day. Closes ↵Rick Olson2007-08-031-0/+9
| | | | | | #8655 [gbuesing] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7262 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Improve various test coverage. Closes #8676 [kamal]Jeremy Kemper2007-06-251-0/+1
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7117 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Add Date#since, ago, beginning_of_day, and end_of_day. Date + seconds works ↵Jeremy Kemper2007-06-041-1/+3
| | | | | | now. Closes #8575. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6937 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Fix imprecise duration addition test. Closes #8516 [Geoff Buesing]Jeremy Kemper2007-05-301-2/+2
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6906 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Time durations use since instead of + for accuracy. Closes #8513.Jeremy Kemper2007-05-301-1/+17
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6901 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Fix chained duration operation tests. Closes #8489 [Geoff Buesing]Jeremy Kemper2007-05-271-4/+4
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6874 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Make 1.months and friends accurate by introducing a Duration class. #6835 ↵Michael Koziarski2007-01-151-0/+47
| | | | | | [eventualbuddha] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5940 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* r4487@asus: jeremy | 2006-04-29 12:21:39 -0700Jeremy Kemper2006-07-081-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Check whether @flash is defined? for warnings-safety. r4488@asus: jeremy | 2006-04-29 12:23:15 -0700 Check whether @flash is defined? for warnings-safety. Obviates nil? check. r4489@asus: jeremy | 2006-04-29 12:45:18 -0700 Check whether @session is defined? for warnings-safety. r4490@asus: jeremy | 2006-04-29 12:50:41 -0700 Check whether @rendering_runtime is defined? for warnings-safety. r4491@asus: jeremy | 2006-04-29 12:55:01 -0700 Check whether @_cycles is defined? for warnings-safety. r4492@asus: jeremy | 2006-04-29 12:59:19 -0700 Check whether instance variables are defined? for warnings-safety. r4493@asus: jeremy | 2006-04-29 13:14:09 -0700 Add nil @template to PrototypeHelperTest to suppress unitialized instance variable warning. r4494@asus: jeremy | 2006-04-29 13:31:34 -0700 Check whether @auto_index defined? for warnings-safety. r4495@asus: jeremy | 2006-04-29 13:32:24 -0700 Wrap content_columns redefinitions with silence_warnings. r4496@asus: jeremy | 2006-04-29 13:35:28 -0700 Wrap more redefinitions with silence_warnings. r4829@asus: jeremy | 2006-07-08 10:59:20 -0700 abstract unit, fix warnings r4830@asus: jeremy | 2006-07-08 11:06:12 -0700 Use parens to silence warning. r4831@asus: jeremy | 2006-07-08 11:06:48 -0700 Use parens to silence warning. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4595 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Added petabytes and exebytes to numeric extensions (closes #2397) ↵David Heinemeier Hansson2005-10-261-1/+3
| | | | | | [timct@mac.com] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2746 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Increased accuracy of 1.year by accounting for leap years. The time ↵Jeremy Kemper2005-06-241-1/+1
| | | | | | extensions are not meant to be super-precise but this seems worth it since otherwise you lose a lot of days doing 40.years.ago. Closes #1488 [tuxie@dekadance.se] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1499 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Moved Active Support into its own gemDavid Heinemeier Hansson2005-02-151-1/+1
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@624 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Fixed errors thrown to namespace collisionDavid Heinemeier Hansson2005-01-151-4/+18
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@421 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Fixed the half applied 393 changesetDavid Heinemeier Hansson2005-01-111-0/+42
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@395 5ecf4fe2-1ee6-0310-87b1-e25e094e27de