Commit Graph

3106 Commits

Author SHA1 Message Date
Edouard CHIN 01eddb390c Rename the class as there is already an existing class with that name 2018-04-06 12:17:58 -04:00
Edouard CHIN 70fae9a434 `SetupAndTeardown#teardown` should call any subsequent after_teardown:
If you have a regular test that have a teardown block, and for any reason an exception get raised, ActiveSupport will not run subsequent after_teardown method provided by other module or gems.
  One of them being the ActiveRecord::TestFixtures which won't rollback the transation when the test ends making all subsequent test to be in a weird state.

  The default implementation of minitest is to run all teardown methods from the user's test, rescue all exceptions, run all after_teardown methods provided by libraries and finally re-raise the exception that happened in the user's teardown method.
  Rails should do the same.
2018-04-06 04:54:56 -04:00
Daniel Colson c1ceafc9d1 Autocorrect `refute` RuboCop violations
73e7aab behaved as expected on codeship, failing the build with
exactly these RuboCop violations. Hopefully `rubocop -a` will
have been enough to get a passing build!
2018-04-03 22:35:49 -04:00
bogdanvlviv 4e68b159d5
Move implementation of `before?` and `after?` to `DateAndTime::Calculations`
This prevents duplication of code.

Prevent duplication of tests by moving them to `DateAndTimeBehavior`.

Related to #32185.
2018-03-31 18:20:46 +03:00
utilum 0548d655f2
Fix: FileStoreTest#test_filename_max_size fails in Ruby 2.5.1 2018-03-31 14:40:59 +01:00
Rafael França 9a9ef9639e
Merge pull request #32185 from nholden/human_readable_date_time_comparisons
Add `before?` and `after?` methods to date and time classes
2018-03-26 18:33:03 -04:00
Rafael França 57e145387b
Merge pull request #32315 from huacnlee/fix/local-cache-read-multi-entry-return
Fix Cache `read_multi` with local_cache bug, should returns raw value, not `ActiveSupport::Cache::Entry` instance.
2018-03-22 19:09:21 -04:00
Kasper Timm Hansen 242ae67ebe
Use try in tests that try to test try. 2018-03-21 21:02:36 +01:00
Jason Lee 4e13a364a6 Fix Cache `read_multi` with local_cache return values.
It should returns raw value, not instance of `ActiveSupport::Cache::Entry`.
2018-03-21 14:16:00 +08:00
Adam Richardson a061ae91a9
Redis cache store: fix constructing with a Redis instance
Since `Redis#call` duck types as a Proc, we'd call `#call` on it,
thinking it's a Proc. Fixed by check for the Proc explicitly instead of
duck typing on `#call`.

References #32233
2018-03-12 18:43:03 -07:00
Nick Holden 20fa0d92c3 Add `before?` and `after?` methods to date and time classes
Equality comparisons between dates and times can take some extra time to
comprehend. I tend to think of a date or time as "before" or "after"
another date or time, but I naturally read `<` and `>` as "less than"
and "greater than." This change seeks to make date/time comparisons more
human readable.
2018-03-06 20:42:49 -08:00
Ashe Connor e52ab31206
URI.unescape handles mixed Unicode/escaped input
Previously, URI.enscape could handle Unicode input (without any actual
escaped characters), or input with escaped characters (but no actual
Unicode characters) - not both.

    URI.unescape("\xe3\x83\x90")  # => "バ"
    URI.unescape("%E3%83%90")  # => "バ"
    URI.unescape("\xe3\x83\x90%E3%83%90")  # =>
                                         # Encoding::CompatibilityError

We need to let `gsub` handle this for us, and then force back to the
original encoding of the input.  The result String will be mangled if
the percent-encoded characters don't conform to the encoding of the
String itself, but that goes without saying.

Signed-off-by: Ashe Connor <ashe@kivikakk.ee>
2018-03-07 12:58:02 +11:00
bogdanvlviv c1ad1f67f9 Deprecate "active_support/core_ext/numeric/inquiry"
Numeric#positive? and Numeric#negative? was added to Ruby since 2.3,
see https://github.com/ruby/ruby/blob/ruby_2_3/NEWS
Rails 6 requires Ruby 2.4.1+ since https://github.com/rails/rails/pull/32034
2018-03-02 23:32:10 -08:00
yuuji.yaginuma acbcec8ea8 Deprecate `active_support/core_ext/hash/compact`
Ruby 2.4+ provides `Hash#compact` and `Hash#compact!` natively,
so `active_support/core_ext/hash/compact` is no longer necessary.
2018-03-02 16:40:55 -08:00
yuuji.yaginuma b1a9cee830 Remove unnecessary `respond_to?(:report_on_exception)` checking
Since Rails 6 requires Ruby 2.4.1+.
2018-03-02 21:26:53 +09:00
Jeremy Daer 4b42c7e52a Ruby 2.4: take advantage of String#unpack1
https://bugs.ruby-lang.org/issues/12752
https://ruby-doc.org/core-2.4.0/String.html#method-i-unpack1
2018-03-01 22:42:51 -08:00
bogdanvlviv d0c697e9b1
Add separate test to ensure that `delegate` with `:private` option returns correct value
Remove extra comments `# Asking for private method` in activesupport/test/core_ext/module_test.rb
Improve docs of using `delegate` with `:private`
Update changelog of #31944
2018-02-28 10:29:12 +02:00
Tomas Valent 06f0675068 add private: true option for ActiveSupport delegate 2018-02-26 20:16:03 +01:00
Gabriel Sobrinho 1077ae96b3
Caching: MemCache and Redis stores use local cache for multi-reads
Fixes #31909.
Closes #31911.
2018-02-23 12:53:01 -08:00
Fumiaki MATSUSHIMA c1d00d6dbf Remove `AS::Multibyte`'s unicode table 2018-02-20 03:58:22 +09:00
Andrew White 2d95956e8b Return all mappings for a timezone id in `country_zones`
Some timezones like `Europe/London` have multiple mappings in
`ActiveSupport::TimeZone::MAPPING` so return all of them instead
of the first one found by using `Hash#value`. e.g:

  # Before
  ActiveSupport::TimeZone.country_zones("GB") # => ["Edinburgh"]

  # After
  ActiveSupport::TimeZone.country_zones("GB") # => ["Edinburgh", "London"]

Fixes #31668.
2018-02-19 10:37:35 +00:00
Jeremy Daer 4940cc49dd String#truncate_bytes: limit to N bytes without breaking multibyte chars
This faithfully preserves grapheme clusters (characters composed of other
characters and combining marks) and other multibyte characters.
2018-02-18 00:14:51 -08:00
Jeremy Daer 8454aeeb2b `String#strip_heredoc` preserves frozenness
```ruby
"foo".freeze.strip_heredoc.frozen?  # => true
```

Fixes the case where frozen string literals would inadvertently become
unfrozen:

```ruby

foo = <<-MSG.strip_heredoc
  la la la
MSG

foo.frozen?  # => false !??
```
2018-02-17 23:02:19 -08:00
Jeremy Daer d4eb0dc89e Rails 6 requires Ruby 2.4.1+
Skipping over 2.4.0 to sidestep the `"symbol_from_string".to_sym.dup` bug.

References #32028
2018-02-17 15:34:57 -08:00
bogdanvlviv 2bfef0d21f Remove extra conditions in HWIDA since Rails 6 does not support Ruby 2.2
See https://github.com/ruby/ruby/blob/ruby_2_3/NEWS
2018-02-17 13:09:30 -08:00
Jeremy Daer 1e526788e6 Rails 6 requires Ruby 2.3+ 2018-02-17 10:03:37 -08:00
Rafael Mendonça França 971e22f43e Define transform_keys! in HashWithIndifferentAccess
Make sure that when transforming the keys of a HashWithIndifferentAccess
we can still access with indifferent access in Ruby 2.5.

Closes #32007.
2018-02-16 21:58:30 -05:00
Rafael Mendonça França 89bcca59e9 Remove usage of strip_heredoc in the framework in favor of <<~
Some places we can't remove because Ruby still don't have a method
equivalent to strip_heredoc to be called in an already existent string.
2018-02-16 19:28:30 -05:00
Rafael Mendonça França 957ca2ed4c Merge pull request #31866 from fatkodima/redis_cache-connection_pool
Add support for connection pooling on RedisCacheStore
2018-02-14 18:23:54 -05:00
yuuji.yaginuma e4719ec047 Add missing require
Without this require, an error occurs when executing only `duration_test.rb`.
Ref: https://travis-ci.org/rails/rails/jobs/338817558#L2205-L2210
2018-02-08 20:05:48 +09:00
Rafael França 5ae2ecab6d
Merge pull request #31923 from jdelStrother/duration-deserialization
Fix yaml deserialization of ActiveSupport::Duration
2018-02-07 15:06:21 -05:00
Jonathan del Strother a467c6bdd5 Fix yaml deserialization of ActiveSupport::Duration
This ensures the duration's @parts hash has a default value, to avoid this regression introduced in 5.1:

  YAML.load(YAML.dump(10.minutes)) + 1  # => NoMethodError: undefined method `+' for nil:NilClass
2018-02-07 13:19:08 +00:00
fatkodima 83c1ed9a1a Use Redis#mget for RedisCacheStore#fetch_multi 2018-02-05 13:51:55 -08:00
fatkodima 3b5d940fe5 Add missing instrumentation to RedisCacheStore#read_multi 2018-02-05 11:57:14 -08:00
fatkodima 08aa8afd24
RedisCacheStore: fix `#write_multi` mset serialization
Closes #31886
Fixes #31884
2018-02-04 17:16:27 -08:00
Ryuta Kamizono 4d99720fd3
Merge pull request #28171 from sorra/fresh-thread-tagged-logging
Improve test for TaggedLogging "keeps each tag in their own thread"
2018-02-03 22:41:39 +09:00
fatkodima dc407392cd Add support for connection pooling on RedisCacheStore 2018-02-01 23:52:20 +02:00
George Claghorn 148d0077c5 Revert "Merge pull request #31447 from fatkodima/redis_cache-connection_pool"
This reverts commit ac74e2c521, reversing
changes made to ffdb061361.
2018-01-31 09:49:32 -05:00
yuuji.yaginuma bee764965e Suppress expected exceptions by `report_on_exception` = `false`
This suppresses `Timeout::Error` exceptions.
Ref: https://travis-ci.org/rails/rails/jobs/334622442#L1089-L1110
2018-01-29 20:37:48 +09:00
Rafael França 2f9549d4f4
Merge pull request #31803 from rmosolgo/rm-dependencies
Fix infinite loop when unloading autoloaded modules
2018-01-26 13:45:08 -05:00
Robert Mosolgo e1ed7a4717 Add failing test for infinite loop when unloading autoloaded modules when an error occured during the load. 2018-01-26 08:59:33 -05:00
Daniel Colson fda1863e1a Remove extra whitespace 2018-01-25 23:32:59 -05:00
Daniel Colson 82c39e1a0b Use assert_empty and assert_not_empty 2018-01-25 23:32:59 -05:00
Daniel Colson 94333a4c31 Use assert_predicate and assert_not_predicate 2018-01-25 23:32:59 -05:00
Daniel Colson 211adb47e7 Change refute to assert_not 2018-01-25 23:32:58 -05:00
Daniel Colson 0d50cae996 Use respond_to test helpers 2018-01-25 23:32:58 -05:00
fatkodima bd54991d20 Improve fault tolerance for redis cache store 2018-01-23 00:34:21 +02:00
fatkodima 4efbbc844b Add support for connection pooling on RedisCacheStore 2018-01-22 13:54:00 -05:00
George Claghorn ebc28aa74a Pass desired driver to Redis client constructor rather than munging global config 2018-01-21 23:59:38 -05:00
Julien Meichelbeck e0f0d717d6 Support hash as first argument in `assert_difference`. (#31600)
* Support hash as first argument for `assert_difference`.

This allows to specify multiple numeric differences in the same assertion.
Example:

    assert_difference 'Article.count' => 1, 'Notification.count' => 2 do
      # post :create, params: { article: {...} }
    end

* Support error message when passing a hash as a first parameter

* Format CHANGELOG properly

[Julien Meichelbeck + Rafael Mendonça França]
2018-01-18 15:20:34 -05:00