aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* | | | | Don't marshal ActiveSupport::Cache::Entry objects twiceSean Griffin2018-03-141-13/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When upgrading to Rails 5.2 we're seeing `ActiveSupport::Cache::Entry#compress` and `ActiveSupport::Cache::Entry#should_compress?` as the highest usage of our CPU. At least some part of this is coming from the fact that objects are being marshaled multiple times. This memoizes the marshaled value to eliminate half the problem.
* | | | | Redis cache store: fix constructing with a Redis instanceAdam Richardson2018-03-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | | | Only apply monkey-patch if detected to be requiredAshe Connor2018-03-091-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We test the failing case we're trying to patch; only if it throws an Exception do we patch. Currently this will *always* throw, but upstream Ruby has patched this bug: https://git.io/vAxKB Signed-off-by: Ashe Connor <ashe@kivikakk.ee>
* | | | | Merge pull request #32183 from kivikakk/uri-ext-fixEileen M. Uchitelle2018-03-071-1/+1
|\ \ \ \ \ | |/ / / / |/| | | | URI.unescape "extension" fails with Unicode input
| * | | | URI.unescape handles mixed Unicode/escaped inputAshe Connor2018-03-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | | | | [ci skip] Hide internal docs from root AS moduleAshe Connor2018-03-061-0/+1
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have a bunch of documentation in lib/active_support/core_ext/object/json.rb which is currently appearing as documentation for the top-level ActiveSupport module. We hide it from rdoc here. Signed-off-by: Ashe Connor <ashe@kivikakk.ee>
* | / / Update skip_after_callbacks_if_terminated documentationRafael Mendonça França2018-03-051-2/+2
| |/ / |/| | | | | | | | | | | Now we always have a terminator, so we don't need to day the options only make sense when the `:terminator` options is specified.
* | | [ci skip] Fix grammar in delegate, private: true docs.Kasper Timm Hansen2018-03-041-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | Convert the user to atheism by ditching the extra example that demonstrates the same thing as date_of_birth. Demonstrate the NoMethodError on date_of_birth first, then call age that uses date_of_birth internally. Thus showing that accessing it publicly fails, but using it internally succeeds.
* | | Deprecate "active_support/core_ext/numeric/inquiry"bogdanvlviv2018-03-023-28/+2
| | | | | | | | | | | | | | | | | | 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
* | | Deprecate `active_support/core_ext/hash/compact`yuuji.yaginuma2018-03-022-27/+2
| | | | | | | | | | | | | | | Ruby 2.4+ provides `Hash#compact` and `Hash#compact!` natively, so `active_support/core_ext/hash/compact` is no longer necessary.
* | | Ruby 2.4: take advantage of String#unpack1Jeremy Daer2018-03-011-2/+2
| | | | | | | | | | | | | | | https://bugs.ruby-lang.org/issues/12752 https://ruby-doc.org/core-2.4.0/String.html#method-i-unpack1
* | | Add separate test to ensure that `delegate` with `:private` option returns ↵bogdanvlviv2018-02-281-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | 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
* | | add private: true option for ActiveSupport delegateTomas Valent2018-02-261-2/+23
| | |
* | | Remove native `Array#sum` and `Enumerable#sum` detection (#32102)Ryuta Kamizono2018-02-261-63/+44
| | | | | | | | | Since #32034, Rails 6 requires Ruby 2.4.1+.
* | | Merge pull request #32093 from jfragoulis/correct-method-documentationYuji Yaginuma2018-02-241-1/+1
|\ \ \ | | | | | | | | Correct method documentation
| * | | Correct ActiveSupport::Deprecation::Behavior#behavior= documentationJohn Fragoulis2018-02-231-1/+1
| | | | | | | | | | | | | | | | | | | | The callback parameters need to reflect changes after https://github.com/rails/rails/pull/28800
* | | | Caching: MemCache and Redis stores use local cache for multi-readsGabriel Sobrinho2018-02-231-0/+17
|/ / / | | | | | | | | | | | | Fixes #31909. Closes #31911.
* | | Call `YAML.load` correctlyeileencodes2018-02-211-1/+1
| | | | | | | | | | | | | | | We should call methods with `.method_name` not `::method_name`. Fix two instances of `YAML::load` I found in favor of `YAML.load`.
* | | Remove `AS::Multibyte`'s unicode tableFumiaki MATSUSHIMA2018-02-202-272/+15
| | |
* | | Return all mappings for a timezone id in `country_zones`Andrew White2018-02-191-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | String#truncate_bytes: limit to N bytes without breaking multibyte charsJeremy Daer2018-02-181-0/+41
| | | | | | | | | | | | | | | This faithfully preserves grapheme clusters (characters composed of other characters and combining marks) and other multibyte characters.
* | | `String#strip_heredoc` preserves frozennessJeremy Daer2018-02-171-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ```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 !?? ```
* | | Fixes typosDharam Gollapudi2018-02-171-3/+3
| | | | | | | | | Fixes typos
* | | Rails 6 requires Ruby 2.4.1+Jeremy Daer2018-02-1710-58/+12
| | | | | | | | | | | | | | | | | | Skipping over 2.4.0 to sidestep the `"symbol_from_string".to_sym.dup` bug. References #32028
* | | Remove require Object#blank? monkey patchSean Collins2018-02-171-1/+0
| | | | | | | | | | | | | | | | | | | | | Object#blank? used to be used in this file, but it's not anymore. This avoids a monkey-patch, for those who want to use just this isolated feature of ActiveSupport.
* | | Remove extra conditions in HWIDA since Rails 6 does not support Ruby 2.2bogdanvlviv2018-02-171-15/+13
| | | | | | | | | | | | See https://github.com/ruby/ruby/blob/ruby_2_3/NEWS
* | | Rails 6 requires Ruby 2.3+Jeremy Daer2018-02-172-31/+17
| | |
* | | Define transform_keys! in HashWithIndifferentAccessRafael Mendonça França2018-02-161-0/+8
| | | | | | | | | | | | | | | | | | | | | Make sure that when transforming the keys of a HashWithIndifferentAccess we can still access with indifferent access in Ruby 2.5. Closes #32007.
* | | Remove usage of strip_heredoc in the framework in favor of <<~Rafael Mendonça França2018-02-161-2/+1
| | | | | | | | | | | | | | | 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.
* | | Add test parallelization to Railseileencodes2018-02-152-0/+188
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Provides both a forked process and threaded parallelization options. To use add `parallelize` to your test suite. Takes a `workers` argument that controls how many times the process is forked. For each process a new database will be created suffixed with the worker number; test-database-0 and test-database-1 respectively. If `ENV["PARALLEL_WORKERS"]` is set the workers argument will be ignored and the environment variable will be used instead. This is useful for CI environments, or other environments where you may need more workers than you do for local testing. If the number of workers is set to `1` or fewer, the tests will not be parallelized. The default parallelization method is to fork processes. If you'd like to use threads instead you can pass `with: :threads` to the `parallelize` method. Note the threaded parallelization does not create multiple database and will not work with system tests at this time. parallelize(workers: 2, with: :threads) The threaded parallelization uses Minitest's parallel exector directly. The processes paralleliztion uses a Ruby Drb server. For parallelization via threads a setup hook and cleanup hook are provided. ``` class ActiveSupport::TestCase parallelize_setup do |worker| # setup databases end parallelize_teardown do |worker| # cleanup database end parallelize(workers: 2) end ``` [Eileen M. Uchitelle, Aaron Patterson]
* | | PERF: symbolize ivar, to reduce dupesSam2018-02-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I noticed this in my memory profiler report. ``` 153 "@default_url_options" 152 /home/sam/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-5.1.4/lib/active_support/core_ext/class/attribute.rb:84 ``` 152 copies of the string `@default_url_options` are retained on the heap in Discourse post boot. Since this is just used for ivar lookups there is no need to use a string.
* | | Merge pull request #31866 from fatkodima/redis_cache-connection_poolRafael Mendonça França2018-02-143-22/+48
|\ \ \ | | | | | | | | | | | | Add support for connection pooling on RedisCacheStore
| * | | Add support for connection pooling on RedisCacheStorefatkodima2018-02-013-22/+48
| | | |
* | | | Doc: fixes typo `cache:` -> `compress:`Joseph Page2018-02-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | [ci skip] Closes #31967
* | | | Merge pull request #31923 from jdelStrother/duration-deserializationRafael França2018-02-071-0/+8
|\ \ \ \ | |_|/ / |/| | | Fix yaml deserialization of ActiveSupport::Duration
| * | | Fix yaml deserialization of ActiveSupport::DurationJonathan del Strother2018-02-071-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | 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
* | | | Use Redis#mget for RedisCacheStore#fetch_multifatkodima2018-02-051-0/+8
| | | |
* | | | Add missing instrumentation to RedisCacheStore#read_multifatkodima2018-02-051-1/+5
| | | |
* | | | Redis cache store: consolidate serializationJeremy Daer2018-02-041-17/+21
| | | | | | | | | | | | | | | | Use `serialize_entry` throughout and introduce `serialize_entries`.
* | | | RedisCacheStore: fix `#write_multi` mset serializationfatkodima2018-02-041-1/+8
| |/ / |/| | | | | | | | | | | Closes #31886 Fixes #31884
* | | Revert "Merge pull request #31447 from fatkodima/redis_cache-connection_pool"George Claghorn2018-01-313-71/+23
| | | | | | | | | | | | | | | This reverts commit ac74e2c521f6ddc0eac02d74a1313261bcc1d60f, reversing changes made to ffdb06136152b3c5f7f4a93ca5928e16e755d228.
* | | Update default deprecation horizonYuji Yaginuma2018-01-311-1/+1
| | | | | | | | | | | | Because the master branch is already 6.0.
* | | Start Rails 6.0 development!!!Rafael Mendonça França2018-01-301-3/+3
| | | | | | | | | | | | :tada::tada::tada:
* | | Merge pull request #31803 from rmosolgo/rm-dependenciesRafael França2018-01-261-0/+1
|\ \ \ | | | | | | | | Fix infinite loop when unloading autoloaded modules
| * | | Remove duplicates after autoloading modulesRobert Mosolgo2018-01-261-0/+1
| | | |
* | | | Improve fault tolerance for redis cache storefatkodima2018-01-231-4/+11
| | | |
* | | | Add support for connection pooling on RedisCacheStorefatkodima2018-01-223-23/+71
|/ / /
* | | Merge pull request #31732 from ↵Matthew Draper2018-01-197-8/+8
|\ \ \ | | | | | | | | | | | | | | | | koic/enable_autocorrect_for_lint_end_alignment_cop Enable autocorrect for `Lint/EndAlignment` cop
| * | | Enable autocorrect for `Lint/EndAlignment` copKoichi ITO2018-01-187-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ### Summary This PR changes .rubocop.yml. Regarding the code using `if ... else ... end`, I think the coding style that Rails expects is as follows. ```ruby var = if cond a else b end ``` However, the current .rubocop.yml setting does not offense for the following code. ```ruby var = if cond a else b end ``` I think that the above code expects offense to be warned. Moreover, the layout by autocorrect is unnatural. ```ruby var = if cond a else b end ``` This PR adds a setting to .rubocop.yml to make an offense warning and autocorrect as expected by the coding style. And this change also fixes `case ... when ... end` together. Also this PR itself is an example that arranges the layout using `rubocop -a`. ### Other Information Autocorrect of `Lint/EndAlignment` cop is `false` by default. https://github.com/bbatsov/rubocop/blob/v0.51.0/config/default.yml#L1443 This PR changes this value to `true`. Also this PR has changed it together as it is necessary to enable `Layout/ElseAlignment` cop to make this behavior.
* | | | Support hash as first argument in `assert_difference`. (#31600)Julien Meichelbeck2018-01-181-7/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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]