aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
Commit message (Collapse)AuthorAgeFilesLines
...
* | | | Merge pull request #31803 from rmosolgo/rm-dependenciesRafael França2018-01-261-0/+55
|\ \ \ \ | | | | | | | | | | Fix infinite loop when unloading autoloaded modules
| * | | | Add failing test for infinite loop when unloading autoloaded modules when an ↵Robert Mosolgo2018-01-261-0/+55
| | | | | | | | | | | | | | | | | | | | error occured during the load.
* | | | | Remove extra whitespaceDaniel Colson2018-01-255-42/+42
| | | | |
* | | | | Use assert_empty and assert_not_emptyDaniel Colson2018-01-258-31/+31
| | | | |
* | | | | Use assert_predicate and assert_not_predicateDaniel Colson2018-01-2526-141/+141
| | | | |
* | | | | Change refute to assert_notDaniel Colson2018-01-251-2/+2
| | | | |
* | | | | Use respond_to test helpersDaniel Colson2018-01-2513-47/+47
| | | | |
* | | | | Improve fault tolerance for redis cache storefatkodima2018-01-234-6/+126
| | | | |
* | | | | Add support for connection pooling on RedisCacheStorefatkodima2018-01-224-50/+91
| | | | |
* | | | | Pass desired driver to Redis client constructor rather than munging global ↵George Claghorn2018-01-211-16/+12
|/ / / / | | | | | | | | | | | | config
* | | | Support hash as first argument in `assert_difference`. (#31600)Julien Meichelbeck2018-01-181-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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]
* | | | Support for connection pooling on mem cache storeGabriel Sobrinho2018-01-181-0/+74
| | | |
* | | | Test against the pure-Ruby Redis driverGeorge Claghorn2018-01-171-0/+6
| | | |
* | | | Fix constant referenceGeorge Claghorn2018-01-161-2/+1
| | | | | | | | | | | | | | | | Update the long key handling test so it triggers truncation in the Redis cache store.
* | | | Merge pull request #30268 from ignatiusreza/instrumentationRyuta Kamizono2018-01-111-6/+6
|\ \ \ \ | | | | | | | | | | | | | | | add instrumentation for read_multi
| * | | | add instrumentation for read_multiIgnatius Reza2017-12-291-6/+6
| | | | | | | | | | | | | | | | | | | | currently it's not possible to know what the hit rates are from read_multi
* | | | | Merge pull request #31648 from dixitp012/rubocop_active_support_testRyuta Kamizono2018-01-081-2/+2
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | Fix rubocop space before comma
| * | | | | Fix rubocop space before commaDixit Patel2018-01-081-1/+1
|/ / / / /
* | | | | Merge pull request #31049 from gwincr11/cg-blankRyuta Kamizono2018-01-041-2/+2
|\ \ \ \ \ | | | | | | | | | | | | Add support for multiple encodings in String.blank?
| * | | | | Add support for multiple encodings in String.blank?Cory Gwin @gwincr112017-11-171-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Motivation: - When strings are encoded with `.encode("UTF-16LE")` `.blank?` throws an `Encoding::CompatibilityError` exception. - We tested multiple implementation to see what the fastest implementation was, rescueing the execption seems to be the fastest option we could find. Related Issues: - #28953 Changes: - Add a rescue to catch the exception. - Added a `Concurrent::Map` to store a cache of encoded regex objects for requested encoding types. - Use the new `Concurrent::Map` cache to return the correct regex for the string being checked.
* | | | | | Merge pull request #31011 from ↵Ryuta Kamizono2018-01-041-0/+11
|\ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | danielma/dma/assert-changes-with-to-should-still-assert-change `assert_changes` should always assert some change
| * | | | | | `assert_changes` should always assert some changeDaniel Ma2017-11-131-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While using `assert_changes`, I came across some unexpected behavior: if you provide a `to:` argument, and the expression matches but didn't actually change, the assertion will pass. The way `assert_changes` reads, I assumed that it would both assert that there was any change at all, _and_ that the expression changed to match my `to:` argument. In the case of just a `from:` argument, `assert_changes` does what I expect as well. It asserts that the before value `=== from` and that the after value changed. My key change is that `assert_changes` will now _always_ assert that expression changes, no matter what combination of `from:` and `to:` arguments
* | | | | | | Merge pull request #31310 from kinnrot/duration-moduloRyuta Kamizono2018-01-011-0/+2
|\ \ \ \ \ \ \ | |_|_|/ / / / |/| | | | | | Duration created with no parts will have a default seconds part eqaul to 0
| * | | | | | Empty duration inspect fixChen Kinnrot2017-12-131-0/+2
| | | | | | |
* | | | | | | Test that cache stores build unversioned keysGeorge Claghorn2017-12-221-0/+12
| | | | | | |
* | | | | | | Handle `FrozenError` if it is availableYasuo Honda2017-12-202-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This pull request handles `FrozenError` introduced by Ruby 2.5. Refer https://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/61131 Since `FrozenError` is a subclass of `RuntimeError` minitest used by master branch can handle it, though it would be better to handle `FrozenError` explicitly if possible. `FrozenError` does not exist in Ruby 2.4 or lower, `frozen_error_class` handles which exception is expected to be raised. This pull request is intended to be merged to master, then backported to `5-1-stable` to address #31508
* | | | | | | Merge pull request #31348 from y-yagi/fix_31283Kasper Timm Hansen2017-12-182-4/+15
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | Raise an error only when `require_master_key` is specified
| * | | | | | | Raise an error only when `require_master_key` is specifiedyuuji.yaginuma2017-12-182-4/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To prevent errors from being raise in environments where credentials is unnecessary. Context: https://github.com/rails/rails/issues/31283#issuecomment-348801489 Fixes #31283
* | | | | | | | Don't include ellipsis in truncated digest outputEugene Kenny2017-12-171-1/+1
|/ / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using `truncate` to limit the length of the digest has the unwanted side effect of adding an ellipsis when the input is longer than the limit. Also: - Don't instantiate a new object for every digest - Rename the configuration option to `hash_digest_class` - Update the CHANGELOG entry to describe how to use the feature
* | | | | | | Suppress `warning: BigDecimal.new is deprecated`Yasuo Honda2017-12-154-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `BigDecimal.new` has been deprecated in BigDecimal 1.3.3 which will be a default for Ruby 2.5. Refer https://github.com/ruby/bigdecimal/commit/533737338db915b00dc7168c3602e4b462b23503 * This commit has been made as follows: ``` cd rails git grep -l BigDecimal.new | grep -v guides/source/5_0_release_notes.md | grep -v activesupport/test/xml_mini_test.rb | xargs sed -i -e "s/BigDecimal.new/BigDecimal/g" ``` - `activesupport/test/xml_mini_test.rb` Editmanually to remove `.new` and `::` - guides/source/5_0_release_notes.md This is a Rails 5.0 release notes.
* | | | | | | Merge pull request #31289 from witlessbird/fips-compatibilityEileen M. Uchitelle2017-12-141-0/+27
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | Initial support for running Rails on FIPS-certified systems
| * | | | | | | Introduced `ActiveSupport::Digest` that allows to specify hash function ↵Dmitri Dolguikh2017-12-121-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | implementation and defaults to `Digest::MD5`. Replaced calls to `::Digest::MD5.hexdigest` with calls to `ActiveSupport::Digest.hexdigest`.
* | | | | | | | Enable `Layout/LeadingCommentSpace` to not allow cosmetic changes in the futureRyuta Kamizono2017-12-1411-47/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Follow up of #31432.
* | | | | | | | Preserve original method visibility when deprecating a methodJordan Brough2017-12-131-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit fixes `deprecate` so that it preserves method visibility (like it did previously when it was utilizing `alias_method_chain`). When Module#prepend replaced alias_method_chain in a982a42 it caused deprecated methods to always become public. `alias_method_chain` had this bit of code: https://github.com/rails/rails/blob/v5.0.6/activesupport/lib/active_support/core_ext/module/aliasing.rb#L40-L47 which preserved method visibility. Without this fix, a workaround would be: ```ruby class C8 private def new_method end def old_method end deprecate :old_method, :new_method # workaround: instance_method(:old_method).owner.send(:private, :old_method) end ``` Because the visibility needs to be fixed on the Module prepended by MethodWrapper.
* | | | | | | | Enable `Layout/SpaceBeforeComma` rubocop rule, and fixed moreRyuta Kamizono2017-12-127-18/+18
|/ / / / / / / | | | | | | | | | | | | | | | | | | | | | Follow up of #31390.
* | | | | | | Refactor Date/Time next_occurring and prev_occurringT.J. Schuck2017-11-282-22/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These methods were originally added in https://github.com/rails/rails/pull/26600 This includes a couple of refactors to make these methods behave more similarly to other Date/Time extensions added by Active Support: 1. Use `advance` instead of `since` and `ago` to time-travel — this is particularly important to keep the returned instance’s class matching `self`. Before this change: today = Date.today # => Tue, 28 Nov 2017 today.class # => Date today.next_occurring(:wednesday) # => Wed, 29 Nov 2017 00:00:00 UTC +00:00 today.next_occurring(:wednesday).class # => ActiveSupport::TimeWithZone After this change, a Date (or Time, or DateTime) instance is properly returned (just like is shown in the new docs). This is generally how everything else in DateAndTime::Calculations works. 2. Move the tests from the DateTime tests to the DateAndTimeBehavior tests. The latter location is mixed in to the core_ext tests for _all_ of Date, Time, and DateTime to test the behavior across all of the classes. The previous location is for testing core_ext functionality added specifically just to DateTime. 3. Better docs!
* | | | | | | Enable `Style/DefWithParentheses` rubocop ruleRyuta Kamizono2017-11-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The def with blank `()` was newly added in #31176, but we have not used the blank `()` style in most part of our code base. So I've enabled `Style/DefWithParentheses` to prevent to newly added the code.
* | | | | | | Renove duplicated and wrong testRafael Mendonça França2017-11-251-5/+0
| | | | | | |
* | | | | | | Merge pull request #24510 from ↵Rafael Mendonça França2017-11-251-0/+11
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | vipulnsward/make-variable_size_secure_compare-public Make variable_size_secure_compare public
| * | | | | | | Changed default behaviour of `ActiveSupport::SecurityUtils.secure_compare`,Vipul A M2017-06-071-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | to make it not leak length information even for variable length string. Renamed old `ActiveSupport::SecurityUtils.secure_compare` to `fixed_length_secure_compare`, and started raising `ArgumentError` in case of length mismatch of passed strings.
* | | | | | | | Make ActiveSupport::TimeZone.all independent of previous lookups (#31176)Chris LaRose2017-11-221-0/+7
| | | | | | | |
* | | | | | | | MemCacheStore: Support expiring countersTakumasa Ochi2017-11-201-0/+16
| |/ / / / / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Support `expires_in` in `ActiveSupport::Cache::MemCacheStore#increment` and `#decrement`. Closes #30716.
* | | | | | | Merge pull request #31035 from BrentWheeldon/bmw-db-load-deadlockMatthew Draper2017-11-181-0/+55
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | Prevent deadlocks with load interlock and DB lock.
| * | | | | | | Prevent deadlocks with load interlock and DB lock.Brent Wheeldon2017-11-091-0/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes an issue where competing threads deadlock each other. - Thread A holds the load interlock but is blocked on getting the DB lock - Thread B holds the DB lock but is blocked on getting the load interlock (for example when there is a `Model.transaction` block that needs to autoload) This solution allows for dependency loading in other threads while a thread is waiting to acquire the DB lock. Fixes #31019
* | | | | | | | Handle `TZInfo::AmbiguousTime` errorsAndrew White2017-11-152-0/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make `ActiveSupport::TimeWithZone` match Ruby's handling of ambiguous times by choosing the later period, e.g. Ruby: ``` ENV["TZ"] = "Europe/Moscow" Time.local(2014, 10, 26, 1, 0, 0) # => 2014-10-26 01:00:00 +0300 ``` Before: ``` >> "2014-10-26 01:00:00".in_time_zone("Moscow") TZInfo::AmbiguousTime: 26/10/2014 01:00 is an ambiguous local time. ``` After: ``` >> "2014-10-26 01:00:00".in_time_zone("Moscow") => Sun, 26 Oct 2014 01:00:00 MSK +03:00 ``` Fixes #17395.
* | | | | | | | These strings should already be frozen where ruby accepts the magic-commentAkira Matsuda2017-11-151-2/+2
| | | | | | | |
* | | | | | | | Cache: Enable compression by default for values > 1kB.Jeremy Daer2017-11-132-3/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Compression has long been available, but opt-in and at a 16kB threshold. It wasn't enabled by default due to CPU cost. Today it's cheap and typical cache data is eminently compressible, such as HTML or JSON fragments. Compression dramatically reduces Memcached/Redis mem usage, which means the same cache servers can store more data, which means higher hit rates. To disable compression, pass `compress: false` to the initializer.
* | | | | | | | Built-in Redis cache storeJeremy Daer2017-11-133-3/+162
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Supports vanilla Redis, hiredis, and Redis::Distributed. * Supports Memcached-like sharding across Redises with Redis::Distributed. * Fault tolerant. If the Redis server is unavailable, no exceptions are raised. Cache fetches are treated as misses and writes are dropped. * Local cache. Hot in-memory primary cache within block/middleware scope. * `read_/write_multi` support for Redis mget/mset. Use Redis::Distributed 4.0.1+ for distributed mget support. * `delete_matched` support for Redis KEYS globs.
* | | | | | | | Merge pull request #30782 from NickLaMuro/improve_performance_of_inflectionsMatthew Draper2017-11-141-0/+6
|\ \ \ \ \ \ \ \ | |_|_|/ / / / / |/| | | | | | | Cache regexps generated from acronym_regex
| * | | | | | | Deprecate ActiveSupport::Inflector#acronym_regexNick LaMuro2017-10-281-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To be removed in Rails 6.0 (default for the deprecate helper). Code moved around as well for the ActiveSupport::Deprecation modules, since it was dependent on ActiveSupport::Inflector being loaded for it to work. By "lazy loading" the Inflector code from within the Deprecation code, we can require ActiveSupport::Deprecation from ActiveSupport::Inflector and not get a circular dependency issue.