aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext
Commit message (Collapse)AuthorAgeFilesLines
...
* | "Use assert_nil if expecting nil from ...:in `...'. This will fail in MT6."Akira Matsuda2016-12-251-1/+1
| |
* | "Use assert_nil if expecting nil. This will fail in minitest 6."Akira Matsuda2016-12-258-16/+16
| |
* | Fix Complex and Rational are duplicable?utilum2016-12-211-2/+2
| | | | | | | | See [this test](https://gist.github.com/utilum/78918f1b64f8b61ee732cb266db7c43a).
* | Fix Fixnum deprecated warning in Ruby 2.4+utilum2016-12-161-1/+1
| |
* | change return value of `duplicable?` with Ruby 2.4+yuuji.yaginuma2016-12-131-2/+7
| | | | | | | | | | | | | | `NilClass`, `FalseClass`, `TrueClass`, `Symbol` and `Numeric` can dup with Ruby 2.4+. Ref: https://bugs.ruby-lang.org/issues/12979
* | :nail_care:Akira Matsuda2016-12-131-2/+1
| |
* | nil, true, 1, etc. don't raise on #dup since Ruby 2.4Akira Matsuda2016-12-131-1/+1
| | | | | | | | https://bugs.ruby-lang.org/issues/12979
* | Exclude singleton classes from `subclasses` and `descendants`Sean Griffin2016-12-011-0/+10
| | | | | | | | | | | | | | | | This behavior changed in Ruby starting with 2.3.0, as a result of https://bugs.ruby-lang.org/issues/11360. This results in a change in behavior of these methods which is likely undesirable. Fixes #27238
* | Treat combined durations as a single unitSean Griffin2016-11-291-0/+11
|/ | | | | | | | | | | | Prior to this commit, `3.months - 3.months` would result in a duration that has the "parts" of `[[:months, 3], [:months, -3]]`. This would mean that it was subtly different than `2.months - 2.months`. When applied to a time, the date might actually change if the resulting day doesn't exist however many months in the future, even though in both cases we just wanted to add `0`, which should always be an identity operation. With this change, we now store the parts as a hash, so `3.months - 3.months` is simply stored as `{ months: 0 }`.
* Merge pull request #27035 from rails/remove-active-support-deprecationsAndrew White2016-11-146-395/+0
|\ | | | | Remove Active Support deprecations
| * Remove deprecated separator argument from parameterizeAndrew White2016-11-141-16/+0
| |
| * Remove deprecated method Numeric#to_formatted_sAndrew White2016-11-141-6/+0
| |
| * Remove deprecated method alias_method_chainAndrew White2016-11-141-215/+0
| |
| * Remove deprecated constant MissingSourceFIleAndrew White2016-11-141-8/+0
| |
| * Remove deprecated Module.qualified_const_get/set/defined?Andrew White2016-11-141-118/+0
| |
| * Remove deprecated :prefix optionAndrew White2016-11-131-15/+0
| |
| * Remove deprecated new_from_hash_copying_defaultAndrew White2016-11-131-7/+0
| |
| * Remove deprecated local_constantsAndrew White2016-11-131-10/+0
| |
* | Revert "Merge pull request #25811 from oss92/to_sentence_fallback_string"Rafael Mendonça França2016-11-141-6/+1
| | | | | | | | | | | | | | | | This reverts commit bad3a120f1690f393d8f6204b3ceee60f0ce707b, reversing changes made to 2384317465ccb1dfca456a2b7798714b99f32711. Reason: Adding a new option in the API for something that can be done with a `#presence` check could do.
* | 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
* Tweaking some test data due to sprintf behavior change in 2.4Akira Matsuda2016-11-051-5/+5
| | | | | | | | 2.3: sprintf('%0.1f', 5.55) #=> "5.5" 2.4: sprintf('%0.1f', 5.55) #=> "5.6" see: https://github.com/ruby/ruby/commit/6ed8c79ddb11ccfb580bb0a22b22cc1362250255 and https://github.com/ruby/ruby/commit/295f60b94d5ff6551fab7c55e18d1ffa6a4cf7e3
* Ensure duration parsing is consistent across DST changesAndrew White2016-10-311-0/+31
| | | | | | | | | | | | | | | | | | Previously `ActiveSupport::Duration.parse` used `Time.current` and `Time#advance` to calculate the number of seconds in the duration from an arbitrary collection of parts. However as `advance` tries to be consistent across DST boundaries this meant that either the duration was shorter or longer depending on the time of year. This was fixed by using an absolute reference point in UTC which isn't subject to DST transitions. An arbitrary date of Jan 1st, 2000 was chosen for no other reason that it seemed appropriate. Additionally, duration parsing should now be marginally faster as we are no longer creating instances of `ActiveSupport::TimeWithZone` every time we parse a duration string. Fixes #26941.
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-2915-793/+793
|
* Fix copy_time_to: Copy nsec instead of usecJosua Schmid2016-10-201-1/+3
| | | | | | | | | | | | | `copy_time_to` is a helper function for date and time calculations. It's being used by `prev_week`, `next_week` and `prev_weekday` to keep the time fraction when jumping around between days. Previously the nanoseconds part was lost during the operation. This lead to problems in practice if you were using the `end_of_day` calculation. Resulting in the time fraction of `end_of_day` not being the same as next week's `end_of_day`. With this fix `copy_time_to` doesn't forget the `nsec` digits.
* Fixnum and Bignum are deprecated in Ruby trunkMatthew Draper2016-10-081-2/+2
| | | | https://bugs.ruby-lang.org/issues/12739
* Revert "Merge pull request #26677 from tbalthazar/26644"Andrew White2016-10-021-6/+0
| | | | | | | | Turns out trying to cache on localtime with arguments is too hard so we'll do it on DateAndTime::Compatibility#to_time instead. This reverts commit 9ce2d1b1a43fc4ef3db59849b7412d30583a4074, reversing changes made to 53ede1aff2025d4391d0e05ba471fdaf3110a99c.
* Fix `ActiveSupport::TimeWithZone#localtime`Thomas Balthazar2016-10-011-0/+6
| | | | | | | | | | | | | | | | | Previously memoization in `localtime` wasn't taking the `utc_offset` parameter into account when returning a cached value. It now caches the computed value depending on the `utc_offset` parameter, e.g: Time.zone = "US/Eastern" t = Time.zone.local(2016,5,2,11) # => Mon, 02 May 2016 11:00:00 EDT -04:00 t.localtime(-7200) # => 2016-05-02 13:00:00 -0200 t.localtime(-3600) # => 2016-05-02 14:00:00 -0100
* Fix ActiveSupport::TimeWithZone#inThomas Balthazar2016-09-241-1/+31
| | | | | | | | | | | | | | | Previously calls to `in` were being sent to the non-DST aware method `Time#since` via `method_missing`. It is now aliased to the DST aware `ActiveSupport::TimeWithZone#+` which handles transitions across DST boundaries, e.g: Time.zone = "US/Eastern" t = Time.zone.local(2016,11,6,1) # => Sun, 06 Nov 2016 01:00:00 EDT -05:00 t.in(1.hour) # => Sun, 06 Nov 2016 01:00:00 EST -05:00
* improve error message when include assertions failMichael Grosser2016-09-164-63/+63
| | | | | | assert [1, 3].includes?(2) fails with unhelpful "Asserting failed" message assert_includes [1, 3], 2 fails with "Expected [1, 3] to include 2" which makes it easier to debug and more obvious what went wrong
* RuboCop is 100% green :tada:Xavier Noria2016-09-021-1/+5
|
* Add three new rubocop rulesRafael Mendonça França2016-08-1613-102/+102
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* Merge pull request #25681 from willnet/fix-thread_mattr_accessorYves Senn2016-08-081-0/+16
|\ | | | | | | Fix `thread_mattr_accessor` share variable superclass with subclass
| * Fix `thread_mattr_accessor` share variable superclass with subclasswillnet2016-08-041-4/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current implementation of `thread_mattr_accessor` set variable sharing superclass with subclass. So the method doesn't work as documented. Precondition class Account thread_mattr_accessor :user end class Customer < Account end Account.user = "DHH" Account.user #=> "DHH" Customer.user = "Rafael" Customer.user # => "Rafael" Documented behavior Account.user # => "DHH" Actual behavior Account.user # => "Rafael" Current implementation set variable statically likes `Thread[:attr_Account_user]`, and customer also use it. Make variable name dynamic to use own thread-local variable.
* | code gardening: removes redundant selfsXavier Noria2016-08-081-8/+8
| | | | | | | | | | | | | | | | | | A few have been left for aesthetic reasons, but have made a pass and removed most of them. Note that if the method `foo` returns an array, `foo << 1` is a regular push, nothing to do with assignments, so no self required.
* | Add `Style/EmptyLines` in `.rubocop.yml` and remove extra empty linesRyuta Kamizono2016-08-074-5/+0
| |
* | applies remaining conventions across the projectXavier Noria2016-08-062-4/+0
| |
* | normalizes indentation and whitespace across the projectXavier Noria2016-08-067-16/+15
| |
* | remove redundant curlies from hash argumentsXavier Noria2016-08-064-18/+18
| |
* | modernizes hash syntax in activesupportXavier Noria2016-08-0612-536/+536
| |
* | applies new string literal convention in activesupport/testXavier Noria2016-08-0655-1204/+1204
|/ | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Add :weeks to the list of variable duration partsAndrew White2016-08-031-0/+32
| | | | | | | | Since 434df00 week durations are no longer converted to days. This means we need to add :weeks to the parts that ActiveSupport::TimeWithZone will consider being of variable duration to take account of DST transitions. Fixes #26039.
* Revert "Adds `not_in?` onto Object"David Heinemeier Hansson2016-07-291-53/+0
|
* Adds `not_in?` onto ObjectJon McCartie2016-07-211-0/+53
|
* define Range#match? if Ruby < 2.4Xavier Noria2016-07-221-0/+24
| | | | | | See the rationale in the documentation included in this patch. We are going to gradually introduce this predicate in the code base.
* Added :fallback_string option to Array#to_sentenceoss922016-07-131-1/+6
|
* AS::Duration should serialize empty values correctly. (#25656)Paul Sadauskas2016-07-111-0/+1
| | | | | | | | | | | | | The current implementation serializes zero-length durations incorrectly (it serializes as `"-P"`), and cannot un-serialize itself: ``` [1] pry(main)> ActiveSupport::Duration.parse(0.minutes.iso8601) ActiveSupport::Duration::ISO8601Parser::ParsingError: Invalid ISO 8601 duration: "-P" is empty duration from /Users/rando/.gem/ruby/2.3.1/gems/activesupport-5.0.0/lib/active_support/duration/iso8601_parser.rb:96:in `raise_parsing_error' ``` Postgres empty intervals are serialized as `"PT0S"`, which is also parseable by the Duration deserializer, so I've modified the `ISO8601Serializer` to do the same. Additionally, the `#normalize` function returned a negative sign if `parts` was blank (all zero). Even though this fix does not rely on the sign, I've gone ahead and corrected that, too, in case a future refactoring of `#serialize` uses it.
* existant => existentAbhishek Jain2016-06-091-1/+1
|
* Improve Hash#compact! documentation and testsIgor Pstyga2016-06-031-0/+8
| | | | | | | Make it clear what should be returned when no changes were made to the hash. { c: true }.compact! # => nil
* Don't blank pad day of the month when formatting datesSean Griffin2016-06-021-0/+11
| | | | | | | | | | | We are currently using `%e` which adds a space before the result if the digit is a single number. This leads to strings like `February 2, 2016` which is undesireable. I've opted to replace with 0 padding instead of removing the padding entirely, to preserve compatibility for those relying on the fact that the width is constant, and to be consistent with time formatting. Fixes #25251.
* Add test for `delegate_missing_to` where method doesn't existJon Moss2016-05-261-0/+8
|