aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext
Commit message (Collapse)AuthorAgeFilesLines
* Expectation firstAkira Matsuda2017-07-021-1/+1
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-0255-55/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Merge pull request #29540 from kirs/rubocop-frozen-stringMatthew Draper2017-07-0255-0/+55
|\ | | | | | | Enforce frozen string in Rubocop
| * Enforce frozen string in RubocopKir Shatrov2017-07-0155-0/+55
| |
* | Merge pull request #29506 from pat/frozen-string-literalsMatthew Draper2017-07-021-9/+10
|\ \ | |/ |/| | | Make ActiveSupport frozen-string-literal friendly.
| * Make ActiveSupport frozen string literal friendly.Pat Allan2017-06-201-9/+10
| | | | | | | | | | | | | | The ActiveSupport test suite only passes currently if it uses the latest unreleased commits for dalli, and a patch for Builder: https://github.com/tenderlove/builder/pull/6 Beyond that, all external dependencies (at least, to the extent they’re used by ActiveSupport) are happy, including Nokogiri as of 1.8.0.
* | prepare for Minitest 6utilum2017-06-201-1/+1
|/
* Implement mattr_acessor :default optionGenadi Samokovarov2017-06-031-1/+37
|
* Add next occur and previous occurred day of week API (#26600)Shota Iguchi2017-05-301-0/+22
|
* Add option for class_attribute default (#29270)David Heinemeier Hansson2017-05-291-1/+9
| | | | | | | | | | | | * Allow a default value to be declared for class_attribute * Convert to using class_attribute default rather than explicit setter * Removed instance_accessor option by mistake * False is a valid default value * Documentation
* Fix implicit calculations with scalars and durationsAndrew White2017-05-201-0/+34
| | | | | | | | | | | | | | | | | | | | | Previously calculations where the scalar is first would be converted to a duration of seconds but this causes issues with dates being converted to times, e.g: Time.zone = "Beijing" # => Asia/Shanghai date = Date.civil(2017, 5, 20) # => Mon, 20 May 2017 2 * 1.day # => 172800 seconds date + 2 * 1.day # => Mon, 22 May 2017 00:00:00 CST +08:00 Now the `ActiveSupport::Duration::Scalar` calculation methods will try to maintain the part structure of the duration where possible, e.g: Time.zone = "Beijing" # => Asia/Shanghai date = Date.civil(2017, 5, 20) # => Mon, 20 May 2017 2 * 1.day # => 2 days date + 2 * 1.day # => Mon, 22 May 2017 Fixes #29160, #28970.
* Update test names to match method nameT.J. Schuck2017-05-041-6/+6
| | | The method is named `delegate_missing_to`, not `delegate_to_missing`
* Remove checks for Enumerator#size methodEugene Kenny2017-04-251-4/+2
| | | | | | | | The Enumerator#size method was introduced in Ruby 2.0. These tests were added when Rails 4.1 was current, and Ruby 1.9.3 was still supported. Since Rails 5 only Ruby >= 2.2.2 is supported, so the checks are no longer necessary.
* Add additional options to time `change` methodsAndrew White2017-04-143-0/+16
| | | | | | | Support `:offset` in `Time#change` and `:zone` or `:offset` in `ActiveSupport::TimeWithZone#change`. Fixes #28723.
* delegate_missing_to should fall back to superMatthew Draper2017-04-091-0/+22
|
* delegate_to_missing doesn't delegate private methodsMatthew Draper2017-04-091-0/+10
| | | | So we shouldn't claim they're there, even when asked explicitly.
* Move HashWithIndifferentAccess tests to separate fileMichael Stock2017-03-301-712/+0
|
* Add aliases for reverse_merge to with_defaultsMatt Casper2017-03-291-0/+25
| | | | | | In the context of controller parameters, reverse_merge is commonly used to provide defaults for user input. Having an alias to reverse_merge called with_defaults feels more idiomatic for Rails.
* Merge pull request #28480 from ↵Rafael Mendonça França2017-03-281-0/+12
|\ | | | | | | | | | | mubashirhanif/add_keep_id_suffix_option_to_humanize_new Add keep id suffix option to humanize new
| * Added options hash to titleize method and keep_id_suffix option to humanizeMubashir Hanif2017-03-211-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | some documentation remove extra whitespace. Added id in the middle test case and corrected some testcases. Some Coding standard guidelines corrections as suggested by codeclimate. Some more corrections suggested by codeclimate.
* | Fix duplicable? for Ratiional and Complex on ruby master, since they are now ↵Vipul A M2017-03-231-1/+4
| | | | | | | | duplicable
* | Fix test warningsAndrew White2017-03-161-5/+5
| |
* | Merge pull request #28147 from kmcphillips/master-time-freezeAndrew White2017-03-162-15/+180
|\ \ | | | | | | Allow Time#to_time on frozen objects. Return frozen time rather than "RuntimeError: can't modify frozen Time"
| * | Handle #to_time and memoization taking into account memoization, frozen ↵Kevin McPhillips2017-03-062-15/+180
| | | | | | | | | | | | state, and preserve_timezone flag.
* | | Remove implicit coercion deprecation of durationsAndrew White2017-03-151-25/+117
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In #28204 we deprecated implicit conversion of durations to a numeric which represented the number of seconds in the duration because of unwanted side effects with calculations on durations and dates. This unfortunately had the side effect of forcing a explicit cast when configuring third-party libraries like expiration in Redis, e.g: redis.expire("foo", 5.minutes) To work around this we've removed the deprecation and added a private class that wraps the numeric and can perform calculation involving durations and ensure that they remain a duration irrespective of the order of operations.
* | | Add `rfc3339` aliases to `xmlschema`Andrew White2017-03-032-0/+15
| | | | | | | | | | | | | | | For naming consistency when using the RFC 3339 profile of ISO 8601 in applications.
* | | Add `Time.rfc3339` parsing methodAndrew White2017-03-031-0/+31
| | | | | | | | | | | | | | | | | | | | | The `Time.xmlschema` and consequently its alias `iso8601` accepts timestamps without a offset in contravention of the RFC 3339 standard. This method enforces that constraint and raises an `ArgumentError` if it doesn't.
* | | Deprecate implicit coercion of `ActiveSupport::Duration`Andrew White2017-03-021-3/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently `ActiveSupport::Duration` implicitly converts to a seconds value when used in a calculation except for the explicit examples of addition and subtraction where the duration is the receiver, e.g: >> 2 * 1.day => 172800 This results in lots of confusion especially when using durations with dates because adding/subtracting a value from a date treats integers as a day and not a second, e.g: >> Date.today => Wed, 01 Mar 2017 >> Date.today + 2 * 1.day => Mon, 10 Apr 2490 To fix this we're implementing `coerce` so that we can provide a deprecation warning with the intent of removing the implicit coercion in Rails 5.2, e.g: >> 2 * 1.day DEPRECATION WARNING: Implicit coercion of ActiveSupport::Duration to a Numeric is deprecated and will raise a TypeError in Rails 5.2. => 172800 In Rails 5.2 it will raise `TypeError`, e.g: >> 2 * 1.day TypeError: ActiveSupport::Duration can't be coerced into Integer This is the same behavior as with other types in Ruby, e.g: >> 2 * "foo" TypeError: String can't be coerced into Integer >> "foo" * 2 => "foofoo" As part of this deprecation add `*` and `/` methods to `AS::Duration` so that calculations that keep the duration as the receiver work correctly whether the final receiver is a `Date` or `Time`, e.g: >> Date.today => Wed, 01 Mar 2017 >> Date.today + 1.day * 2 => Fri, 03 Mar 2017 Fixes #27457.
* | | Update `DateTime#change` to support usec and nsecAndrew White2017-03-021-11/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adding support for these options now allows us to update the `DateTime#end_of` methods to match the equivalent `Time#end_of` methods, e.g: datetime = DateTime.now.end_of_day datetime.nsec == 999999999 # => true Fixes #21424.
* | | Add Duration#before and #after as aliases for #ago and #sinceNick Johnstone2017-02-261-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's common in test cases at my job to have code like this: let(:today) { customer_start_date + 2.weeks } let(:earlier_date) { today - 5.days } With this change, we can instead write let(:today) { 2.weeks.after(customer_start_date) } let(:earlier_date) { 5.days.before(today) } Closes #27721
* | | Merge pull request #28157 from robin850/hwia-soft-deprecationMatthew Draper2017-02-251-0/+28
|\ \ \ | | | | | | | | | | | | Soft-deprecate the `HashWithIndifferentAccess` constant
| * | | Add few tests for the top level `HashWithIndifferentAccess`Robin Dupret2017-02-251-0/+24
| | | | | | | | | | | | | | | | | | | | This ensures that if we try to hard-deprecate it again in the future, we won't break these behaviors.
| * | | Soft-deprecate the top-level HashWithIndifferentAccess classRobin Dupret2017-02-251-0/+4
| |/ / | | | | | | | | | | | | | | | | | | Since using a `ActiveSupport::Deprecation::DeprecatedConstantProxy` would prevent people from inheriting this class and extending it from the `ActiveSupport::HashWithIndifferentAccess` one would break the ancestors chain, that's the best option we have here.
* / / add optional second argument to ActiveSupport core extension for ↵Jeff Latz2017-02-241-0/+13
|/ / | | | | | | Marshal#load so it can take a proc
* | Make HWIA#compact not return nil when no nilsPavel Pravosud2017-02-231-0/+10
| |
* | Add more missing requiresAndrew White2017-02-221-0/+1
| | | | | | | | Further missing requires for Timeout exposed due to Bundler 1.14.5
* | Preload to_datetime before freezing a TimeWithZone instanceAdam Rice2017-02-221-0/+1
| |
* | Revert "Merge pull request #27925 from robin850/hwia-removal"Kasper Timm Hansen2017-02-201-23/+0
| | | | | | | | | | | | | | | | | | Pointed out by @matthewd that the HWIA subclass changes the AS scoped class and top-level HWIA hierarchies out from under existing classes. This reverts commit 71da39097b67114329be6d8db7fe6911124531af, reversing changes made to 41c33bd4b2ec3f4a482e6030b6fda15091d81e4a.
* | Deprecate the top-level `HashWithIndifferentAccess` contantRobin Dupret2017-02-191-0/+23
| | | | | | | | | | | | | | | | | | This constant was kept for the sake of backward compatibility; it is still available under `ActiveSupport::HashWithIndifferentAccess`. Furthermore, since Ruby 2.5 (https://bugs.ruby-lang.org/issues/11547) won't support top level constant lookup, people would have to update their code anyway.
* | Add Time#blank? to blank_testkenta-s2017-02-121-1/+1
| |
* | Merge pull request #27919 from bf4/correct_spellingArthur Nogueira Neves2017-02-061-2/+2
|\ \ | | | | | | Correct spelling
| * | Correct spellingBenjamin Fleischer2017-02-051-2/+2
| | | | | | | | | | | | | | | | | | | | | ``` go get -u github.com/client9/misspell/cmd/misspell misspell -w -error -source=text . ```
* | | Add tests for `blank?`kenta-s2017-02-063-0/+12
|/ /
* | Uninterned Symbol can be duped since ruby 2.4.1Akira Matsuda2017-01-261-1/+4
| | | | | | | | | | | | https://github.com/ruby/ruby/commit/11e6bd5ac2a2eebfa589bd6db8c9c4daa337733e Leaving the 2.4.0 conditional for now, in order never to forget backporting r57407 to 2.4.1
* | Give a message to `#test_duplicable` assertionyui-knk2017-01-251-1/+1
| | | | | | | | | | Giving a message helps us to know what happened when we look at Travis CI.
* | Allocation free Integer#to_sJean Boussier2017-01-191-0/+4
| |
* | Unused class for testing since 93559da4826546d07014f8cfa399b64b4a143127Akira Matsuda2017-01-181-16/+0
| |
* | Adjust `Module.parent_name` to work when frozen; fixes #27637Corey Ward2017-01-172-30/+37
| |
* | Constant look-up would no longer fall back to top-level constant since ruby 2.5Akira Matsuda2017-01-131-2/+2
| | | | | | | | | | See: https://github.com/ruby/ruby/commit/44a2576f798b07139adde2d279e48fdbe71a0148 https://github.com/ruby/ruby/commit/9df88e9cae57aa421230f14500e88f33f127414f
* | class Foo < Struct.new(:x) creates an extra unneeded anonymous classAkira Matsuda2017-01-131-1/+1
| | | | | | | | because Struct.new returns a Class, we just can give it a name and use it directly without inheriting from it