aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/duration_test.rb
Commit message (Collapse)AuthorAgeFilesLines
...
* | Follow-up to #16560Robin Dupret2014-08-241-5/+6
| | | | | | | | | | | | | | For the sake of backward-compatibility, we need to make #instance_of? return true for Fixnum. On the other hand, the method should still give true for ActiveSupport::Duration itself which was not the case before.
* | Define the Duration#instance_of? methodRobin Dupret2014-08-181-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | Since Duration is extending from ProxyObject which extends itself from BasicObject, the Duration object doesn't respond to the #instance_of? method. Thus, the #method_missing hook get triggered, delegating the method to its `value` attribute. However, Rubinius' #eql? definition relies on #instance_of?, thus this will equal to true with a Fixnum (since its `value` attribute is a Fixnum) while it should not. The previous behavior was wrong anyway, no matter the implementation.
* | missing activesupport test coverageEugene Gilburg2014-07-191-0/+4
| |
* | Extract out with_env_tz helper method.Zuhao Wan2014-06-181-8/+3
| | | | | | | | | | It’s used at so many places that extracting it out into a helper file is worth doing.
* | Fixed problem where `1.day.eql?(1.day)` is falseEmily Dobervich2014-04-081-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes: 1.second.eql?(1.second) #=> false The new `eql?` requires that `other` is an `ActiveSupport::Duration`. This requirement makes `ActiveSupport::Duration`'s behavior consistent with other numeric types in Ruby. 1.eql?(1.0) #=> false 1.0.eql?(1) #=> false 1.second.eql?(1) #=> false (was true) 1.eql?(1.second) #=> false { 1 => "foo", 1.0 => "bar" } #=> { 1 => "foo", 1.0 => "bar" } { 1 => "foo", 1.second => "bar" } # now => { 1 => "foo", 1.second => "bar" } # was => { 1 => "bar" } And though the behavior here hasn't changed, for reference: 1 == 1.0 #=> true 1.0 == 1 #=> true 1 == 1.second #=> true 1.second == 1 #=> true
* | Prefer assert_raise instead of flunk + rescue to test for exceptionsCarlos Antonio da Silva2013-12-191-5/+3
| | | | | | | | | | | | Change most tests to make use of assert_raise returning the raised exception rather than relying on a combination of flunk + rescue to check for exception types/messages.
* | Fix segmentation fault in Ruby 2.0.0-p353.Dmitriy Kiriyenko2013-11-301-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | In Ruby 2.0.0-p353 there was a [commit](https://github.com/ruby/ruby/commit/66915c507777c5e3a978fa73de25db763efd9206) that switched case matching from actual sending `===` method to magic lookup, that does not see it in `method_missing`. It's hard to predict how exactly and when exactly this bug will be solved so here I suggest a solution of defining it in Duration directly. In Ruby 2.0.0-p353 without the added fix added test crashes to segmentation fault.
* | Deprecated Numeric#{ago,until,since,from_now}Godfrey Chan2013-11-261-4/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Revert "Merge pull request #12480 from iwiznia/master"Jeremy Kemper2013-10-111-15/+0
| | | | | | | | | | This reverts commit e5f5a838b96a362534d9bb60d02334439ed9784c, reversing changes made to d7567f3290a50952494e9213556a1f283a6cf3a0.
* | flatten and flatten! methods for ActiveSupport::DurationIonatan Wiznia2013-10-111-0/+15
| |
* | Reduce Duration#inspect to a single series of transformationsDavid Chelimsky2013-09-111-0/+3
|/ | | | | | | | | | | * eliminates need for temp Hash Also added a couple of examples to DurationTest to specify: * duration can be defined with units out of order e.g. 1.month + 1.year + 1.second + 1.day * equality with a Fixnum works regardless of which operand is on which side of the operator
* Remove unnecessary begin..rescue..end, use only rescueAkira Matsuda2013-01-061-8/+6
|
* Rename ActiveSupport::BasicObject to ActiveSupport::ProxyObjectFrancesco Rodriguez2012-12-071-2/+2
| | | | | AS::BasicObject is used for proxy classes. Let's give it a less concerning name. Also, it avoids the confusion with Ruby's Basic Object.
* Missing dependency for duration test.Rolf Timmermans2011-03-131-0/+1
|
* 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]
* Fix Duration#to_jsonPratik Naik2010-12-291-0/+5
|
* Exception handling more readableThiago Pradi2010-09-191-2/+2
| | | | | | [#5601 state:committed] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Make ActiveSupport::Duration#method_missing delegate blocks to value [#5498 ↵Krekoten' Marjan2010-09-011-0/+8
| | | | | | state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* Deletes trailing whitespaces (over text files only find * -type f -exec sed ↵Santiago Pastorino2010-08-141-2/+2
| | | | 's/[ \t]*$//' -i {} \;)
* 1.day should respond_to kind_of tooNeeraj Singh2010-05-211-0/+1
| | | | | | [#4656 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* Final iteration of use better testing methodsNeeraj Singh2010-05-191-2/+2
| | | | | | [#4652 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* Remove unneeded reliance on super -> method_missing quirkJeremy Kemper2010-01-071-0/+25
|
* make #inspect if zero length duration return '0 seconds' instead of empty ↵Levin Alexander2009-07-021-0/+1
| | | | | | string [#2838 state:resolved] Signed-off-by: Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>
* Remove 'core' fluff. Hookable ActiveSupport.load_all!Jeremy Kemper2009-05-201-1/+1
|
* Work around Float faux precisionJeremy Kemper2009-04-301-10/+10
|
* Fix dependencies revealed by testing in isolationJeremy Kemper2009-04-221-0/+1
|
* Merge branch 'master' into cherryJeremy Kemper2009-04-201-0/+12
|\ | | | | | | | | | | | | | | | | | | | | Conflicts: activesupport/CHANGELOG activesupport/lib/active_support/core_ext/class/delegating_attributes.rb activesupport/lib/active_support/core_ext/hash/conversions.rb activesupport/lib/active_support/core_ext/module/attribute_accessors.rb activesupport/lib/active_support/core_ext/string/multibyte.rb activesupport/lib/active_support/core_ext/time/calculations.rb activesupport/lib/active_support/deprecation.rb
| * Time.local instances: Adding 24.hours across the DST boundary adds 24 hours ↵Michael Curtis2009-03-291-0/+12
| | | | | | | | instead of one day [#2066 state:resolved]
* | * Introduce ActiveSupport.core_ext Integer, %w(conversions time etc)Jeremy Kemper2009-03-211-20/+0
|/ | | | | | * Convert some extension modules to simply reopening the class * Remove deprecated Float time extensions * Fold Base64 extension into ActiveSupport::Base64 since stdlib Base64 is gone
* Remove obsolete silence_warnings wrappers from TZInfo-dependent tests in ↵Levin Alexander2009-02-141-13/+11
| | | | ActiveSupport [#1914 state:resolved]
* Require mocha >= 0.9.0 for AS testsJeremy Kemper2008-11-221-60/+58
|
* Subclass AS::TestCase to get custom assertionsJeremy Kemper2008-11-071-1/+1
|
* Fix test warningsPratik Naik2008-10-171-2/+2
|
* Enhance testing for fractional days and weeks. Update changelog.gbuesing2008-10-131-13/+9
|
* Added deprecated warning messages to Float#months and Float#years deprications.Tom Lea2008-10-131-8/+10
|
* Deprecated Float#years and Float#months, moved Numeric#years and ↵Tom Lea2008-10-131-0/+18
| | | | Numeric#months into Integer.
* Time#advance recognizes fractional days and weeks [#970 state:resolved]Tom Lea2008-10-131-0/+34
|
* Namespace Inflector, Dependencies, OrderedOptions, and TimeZone under ↵Joshua Peek2008-06-031-4/+4
| | | | ActiveSupport [#238 state:resolved]
* Duration #since and #ago with no argument (e.g., 5.days.ago) return ↵gbuesing2008-04-201-0/+42
| | | | TimeWithZone when config.time_zone is set. Introducing Time.current, which returns Time.zone.now if config.time_zone is set, otherwise just returns Time.now
* 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: add #raise to AS::BasicObject, fixup Duration argument ↵Jeremy Kemper2008-01-021-0/+11
| | | | | | error. Closes #10594. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8523 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 Duration test failing with Ruby 1.9Jeremy Kemper2007-09-271-2/+3
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7648 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Improve test coverage of Duration. Closes #7182 [richcollins]Michael Koziarski2007-01-211-0/+4
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6007 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Fix that Dates couldn't be subtracted from Dates after [5940].Sam Stephenson2007-01-151-1/+5
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5954 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Make 1.months and friends accurate by introducing a Duration class. #6835 ↵Michael Koziarski2007-01-151-0/+13
[eventualbuddha] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5940 5ecf4fe2-1ee6-0310-87b1-e25e094e27de