aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/duration_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Removed mocha stubbing in active_supportRonak Jangir2015-06-071-16/+18
|
* Removing :en in favor of I18n.default_locale in duration#inspectDominik Masur2015-01-121-0/+9
| | | | | | | | | | | | | | | | | Hi there, i have an app without english as available locale. So i got an error when we try to inspect something like 1.day. This is done automatically when we use the dalli cache. I would like to change the :en to ::I18n.default_locale to be sure that this is always constant and is an available locale. Tests are all green with this change. Calculating ------------------------------------- :locale => :en 2.024k i/100ms :locale => ::I18n.default_locale 2.236k i/100ms ------------------------------------------------- :locale => :en 25.758k (±26.3%) i/s - 117.392k :locale => ::I18n.default_locale 26.311k (±18.1%) i/s - 127.452k
* Merge pull request #17493 from petewest/duration-comparableAaron Patterson2014-11-071-0/+12
|\ | | | | Delegate comparison operator to value
| * Delegate comparison operator to valuePeter West2014-11-031-0/+12
| |
* | Removed the unused require of proxy_object and test related to itPrathamesh Sonpatki2014-11-051-1/+0
|/ | | | | - Reference : https://github.com/rails/rails/pull/17493#issuecomment-61739359 - Duration stopped inheriting from ProxyObject in https://github.com/rails/rails/pull/16574
* define hash on durationlsylvester2014-10-031-0/+4
|
* Fix another false assertionsYuki Nishijima2014-09-211-2/+2
| | | | | | | | | | | | * The assertions in AS::Duration don't actually assert. * The assertion in Railtie will pass even when `eager_load_namespaces` doesn't include `AppTemplate::Application` if `Rails.application` is truthy. For more details, see here: * https://github.com/rails/rails/pull/16998 * https://github.com/rails/rails/pull/17000
* Merge pull request #11794 from yoazt/duration-eqlRafael Mendonça França2014-09-171-0/+4
|\ | | | | | | | | | | | | | | | | Added method `#eql?` to `ActiveSupport::Duration`, in addition to `#==`. Conflicts: activesupport/CHANGELOG.md activesupport/lib/active_support/duration.rb activesupport/test/core_ext/duration_test.rb
| * Added method `#eql?` to `ActiveSupport::Duration`, in addition to `#==`.Joost Lubach2013-08-071-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | Currently, the following returns `false`, contrary to expectation: 1.minute.eql?(1.minute) Adding method `#eql?` will make this behave like expected. Method `#eql?` is just a bit stricter than `#==`, as it checks whether the argument is also a uration. Their parts may be different though. 1.minute.eql?(60.seconds) # => true 1.minute.eql?(60) # => false
* | add implementation of respond_to? for ActiveSupport::Durationlsylvester2014-09-151-0/+9
| |
* | Skip #eql? tests on Rubinius for AS::DurationRobin Dupret2014-08-241-0/+3
| | | | | | | | | | | | | | | | | | Since Rubinius is relying on #instance_of? for its definition of #eql? (http://git.io/MtmbbA) but ActiveSupport::Duration should behave like is_a? it returns true with `Fixnum`. Thus, for the moment, the last assertion is failing so we have to skip this test.
* | 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