aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
Commit message (Collapse)AuthorAgeFilesLines
...
| * | | Windows support for parallelization and instrumenterGannon McGibbon2018-11-082-2/+7
| |/ / | | | | | | | | | | | | Add Windows support for `ActiveSupport::Testing::Parallelization` and `ActiveSupport::Notifications::Instrumenter`.
* / / Correctly handle unknown object in parallel testsyuuji.yaginuma2018-11-171-0/+2
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DRb wraps in `DRbUnknown` if the data contains a type that can not be resolved locally. This can happen if an error occurs in the test and the error class can not be resolved on the server side. When this happens, an instance of `DRbUnknown` is passed to the `result` of `Server#record`. This causes another error(undefined method assertions for #<DRb::DRbUnknown:> (NoMethodError)) in `reporter.record`. This can confirm by the following steps. ``` $ rails new app -B --dev; cd app $ rails g scaffold user name:string $ edit `config.action_controller.allow_forgery_protection = true` in environments/test.rb $ bin/rails t ``` In the case of `DRbUnknown` occurs, can't resolve error exception. So wrap exception with `DRbRemoteError` in the same way as an unmarshalled object.
* | Merge pull request #34131 from lsylvester/defend-against-unmarshable-exceptionsEileen M. Uchitelle2018-11-051-1/+8
|\ \ | | | | | | Fix DRb::DRbServerNotFound errors in parallel tests
| * | resque errors caused by Marshal dump failures and wrap exceptions in ↵Lachlan Sylvester2018-10-091-1/+8
| | | | | | | | | | | | marshallable DRbRemoteError
* | | Make #to_options an alias for #symbolize_keysNick Weiland2018-11-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes #34359 Prior to 5.2.0 (2cad8d7), HashWithIndifferentAccess#to_options acted as an alias to HashWithIndifferentAccess#symbolize_keys. Now, #to_options returns an instance of HashWithIndifferentAccess while #symbolize_keys returns and instance of Hash. This pr makes it so HashWithIndifferentAccess#to_options acts as an alias for HashWithIndifferentAccess#symbolize_keys once again.
* | | Missing require "active_support/executor"Akira Matsuda2018-10-301-0/+1
| | |
* | | Missing require "core_ext/module/attribute_accessors"Akira Matsuda2018-10-301-0/+1
| | |
* | | Missing require "active_support/concern"Akira Matsuda2018-10-301-0/+2
| | |
* | | Merge pull request #34334 from ↵Ryuta Kamizono2018-10-291-2/+3
|\ \ \ | | | | | | | | | | | | | | | | albertoalmagro/privatize-constants-activesupport-timezone Privatize and add # :nodoc: to constants
| * | | Privatize and add # :nodoc: to constantsAlberto Almagro2018-10-281-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | Both `UTC_OFFSET_WITH_COLON` and `UTC_OFFSET_WITHOUT_COLON` are only used within `ActiveSupport::TimeZone` and in my opinion they do not provide relevant information that should appear in the docs.
* | | | Improve the logic that detects non-autoloaded constantsJan Habermann2018-10-281-1/+5
|/ / / | | | | | | | | | | | | | | | | | | If you require `nokogiri` from `app/models/user.rb`, dependencies.rb does not mark `Nokogiri` as an autoloaded constant, as expected. But the logic to detect these non-autoloaded constants is incomplete. See the tests defined in the patch for some cases incorrectly handled.
* | | Merge pull request #34208 from yskkin/inspect_with_parameter_filterRyuta Kamizono2018-10-261-22/+40
|\ \ \ | | | | | | | | Implement AR#inspect using ParameterFilter
| * | | Implement AR#inspect using ParamterFilter.Yoshiyuki Kinjo2018-10-191-22/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | AR instance support `filter_parameters` since #33756. Though Regex or Proc is valid as `filter_parameters`, they are not supported as AR#inspect. I also add :mask option and #filter_params to `ActiveSupport::ParameterFilter#new` to implement this.
* | | | `assert_called_with` should require `args` argumentbogdanvlviv2018-10-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are two main reasons why `assert_called_with` should require `args` argument: 1) If we want to assert that some method should be called and we don't need to check with which arguments it should be called then we should use `assert_called`. 2) `assert_called_with` without `args` argument doesn't assert anything! ```ruby assert_called_with(@object, :increment) do @object.decrement end ``` It causes false assertions in tests that could cause regressions in the project. I found this bug by working on [minitest-mock_expectations](https://github.com/bogdanvlviv/minitest-mock_expectations) gem. This gem is an extension for minitest that provides almost the same method call assertions. I was wondering whether you would consider adding "minitest-mock_expectations" to `rails/rails` instead of private `ActiveSupport::Testing::MethodCallAssertions` module. If yes, I'll send a patch - https://github.com/bogdanvlviv/rails/commit/a970ecc42c3a9637947599f2c13e3762e4b59208
* | | | Merge pull request #34034 from runephilosof/patch-2Gannon McGibbon2018-10-241-0/+3
|\ \ \ \ | | | | | | | | | | Make it easier to find abort documentation
| * | | | Make it easier to find abort documentationRune Philosof2018-10-011-0/+3
| | |_|/ | |/| | | | | | Make sure how to abort is documented on https://api.rubyonrails.org/classes/ActiveSupport/Callbacks.html
* | | | Add docs to ActiveSupport::Notifications.subscribeChris Fung2018-10-221-0/+18
| | | | | | | | | | | | | | | | [ci skip]
* | | | Rename event variableAlberto Almagro2018-10-211-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Improve variable naming by renaming from `e` to `event`. The arguments to rename this are: * The naming `e` is usually a convention used for exceptions. * No other method in this class uses the naming `e`. All other methods are using `event`.
* | | | Use String#truncate_bytes inside Multibyte::Chars#limitFrancesco Rodríguez2018-10-201-13/+1
| | | |
* | | | Consistently use kwargs for `instance_{reader,writer,accessor}` optionsRyuta Kamizono2018-10-202-19/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since #29294, `mattr_acessor` uses kwargs for `instance_reader`, `instance_writer`, and `instance_accessor` options. `thread_mattr_accessor` and `config_accessor` also take the same options, so let's maintain these options handles the same.
* | | | Missing require "active_support/number_helper/number_converter"Akira Matsuda2018-10-207-0/+14
| | | |
* | | | Missing require "concurrent/hash"Akira Matsuda2018-10-201-0/+1
| | | |
* | | | Missing require "active_support/callbacks"Akira Matsuda2018-10-201-0/+2
| | | |
* | | | ActiveSupport module may not always already defined hereAkira Matsuda2018-10-202-150/+154
| | | | | | | | | | | | | | | | `ruby -ractive_support/core_ext/range/conversions.rb -ep` dies with uninitialized constant ActiveSupport
* | | | Missing require "active_support/dependencies/autoload"Akira Matsuda2018-10-201-0/+2
| | | |
* | | | attribute_accessors no longer uses extract_options since ↵Akira Matsuda2018-10-201-2/+0
| | | | | | | | | | | | | | | | a5b0c60714e1e8d8c182af830a26e1c7c884271d
* | | | Deprecate Unicode's #pack_graphemes and #unpack_graphemes methodsFrancesco Rodríguez2018-10-181-0/+10
| | | | | | | | | | | | | | | | in favor of `array.flatten.pack("U*")` and `string.scan(/\X/).map(&:codepoints)`, respectively.
* | | | Refactor Chars#reverse and Chars#grapheme_lengthFrancesco Rodríguez2018-10-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use \X meta character directly to get grapheme clusters. Thanks to @mtsmfm for the tip: https://github.com/rails/rails/pull/34123#issuecomment-429028878 r? @jeremy
* | | | Merge pull request #34056 from CaDs/CaDs-extend_documentation_for_fetch_multiRichard Schneeman2018-10-161-2/+11
|\ \ \ \ | | | | | | | | | | Extend doc for ActiveSupport::Cache#fetch_multi
| * | | | Extends documentation for ActiveSupport::Cache#fetch_multi [ci skip]Carlos Donderis2018-10-161-2/+11
| | | | |
* | | | | Deprecate ActiveSupport::Multibyte::Chars.consumes?Francesco Rodríguez2018-10-151-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In favor of String#is_utf8?. I think this method was made for internal use only, and its usage was removed here: https://github.com/rails/rails/pull/8261/files#diff-ce956ebe93786930e40f18db1da5fd46L39.
* | | | | Fix issue where duration where always rounded up to a second:Edouard CHIN2018-10-121-1/+1
| |_|/ / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Adding a Float as a duration to a datetime would result in the Float being rounded. Doing something like would have no effect because the 0.45 seconds would be rounded to 0 second. ```ruby time = DateTime.parse("2018-1-1") time += 0.45.seconds ``` This behavior was intentionally added a very long time ago, the reason was because Ruby 1.8 was using `Integer#gcd` in the constructor of Rational which didn't accept a float value. That's no longer the case and doing `Rational(0.45, 86400)` would now perfectly work fine. - Fixes #34008
* | | | Deprecate Unicode#normalize and Chars#normalize (#34202)Francesco Rodríguez2018-10-123-16/+44
| | | |
* | | | Use native String#capitalizeFrancesco Rodríguez2018-10-121-8/+1
| | | |
* | | | Deprecate Unicode#downcase/upcase/swapcase.Francesco Rodríguez2018-10-122-33/+11
| | | | | | | | | | | | | | | | Use String methods directly instead.
* | | | Merge pull request #34105 from zvkemp/correct-asn-docsGannon McGibbon2018-10-091-2/+2
|\ \ \ \ | |_|_|/ |/| | | clarify role of unique_id in ActiveSupport::Notifications [ci skip]
| * | | clarify role of unique_id in ActiveSupport::Notificationszvkemp2018-10-051-2/+2
| | | |
* | | | Deprecate ActionDispatch::Http::ParameterFilter in favor of ↵Yoshiyuki Kinjo2018-10-081-0/+106
| | | | | | | | | | | | | | | | ActiveSupport::ParameterFilter
* | | | Array with single item correctly uses cache_keyGraham Turner2018-10-051-1/+1
|/ / /
* | | Merge pull request #34068 from schneems/schneems/micro-optimize-try-nilRichard Schneeman2018-10-051-2/+2
|\ \ \ | | | | | | | | 23% faster Nil#try
| * | | This PR speeds up Nil#try by avoiding an allocation when only one argument ↵schneems2018-10-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | is passed: ```ruby class FooNew def try(method_name = nil, *args) nil end end class FooOld def try(*args) nil end end require 'benchmark/ips' foo_new = FooNew.new foo_old = FooOld.new Benchmark.ips do |x| x.report("new") { foo_new.try(:anything) } x.report("old") { foo_old.try(:anything) } x.compare! end # Warming up -------------------------------------- # new 250.633k i/100ms # old 232.322k i/100ms # Calculating ------------------------------------- # new 6.476M (± 4.8%) i/s - 32.332M in 5.005777s # old 5.258M (± 3.2%) i/s - 26.485M in 5.042589s # Comparison: # new: 6476002.5 i/s # old: 5257912.5 i/s - 1.23x slower ``` It's worth noting that checking for nil separately as in https://github.com/rails/rails/pull/34067 seems to be MUCH faster. It might be worth it to apply a blanket `&.` to every internal `try` call.
* | | | Bugfix: ActiveSupport::EncryptedConfiguration reading of comment-only ↵Martin Spickermann2018-10-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | encrypted files (#34014) * Fix reading comment only encrypted files When a encrypted file contains only comments then reading that files raises an error: NoMethodError: undefined method `deep_symbolize_keys' for false:FalseClass activesupport/lib/active_support/encrypted_configuration.rb:33:in `config' test/encrypted_configuration_test.rb:52:in `block in <class:EncryptedConfigurationTest>' This happens because the previous implementation returned a `{}` fallback for blank YAML strings. But it did not handle YAML strings that are present but still do not contain any _usefull_ YAML - like the file created by `Rails::Generators::EncryptedFileGenerator` which looks like this: # aws: # access_key_id: 123 # secret_access_key: 345 * Fix coding style violation * Add backwardscompatible with Psych versions that were shipped with Ruby <2.5 * Do not rely on railties for Active Support test * Simplify error handling * Improve test naming * Simplify file creation in test
* | | | Merge pull request #33936 from schneems/schneems/cache-micro-optimizationsRichard Schneeman2018-10-041-2/+6
|\ \ \ \ | | | | | | | | | | Decrease memory allocations in cache.rb
| * | | | Decrease memory allocations in cache.rbschneems2018-09-211-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `merged_options` method is private and the output is never mutated. Using this info we can get rid of the `dup` behavior. We can also eliminate the `merge` call in the case where all the options being merged are the same. Returned results are frozen as an extra layer of protection against mutation. Before ``` Total allocated: 741749 bytes (6642 objects) ``` After ``` Total allocated: 734039 bytes (6648 objects) ``` Diff ``` (741749 - 734039) / 741749.0 => ~ 1.0 % ``` If you don't feel comfortable modifying this method, we could rename it and only use it internally.
* | | | | Merge pull request #34055 from Edouard-chin/ec-logger-fixRafael França2018-10-033-19/+27
|\ \ \ \ \ | | | | | | | | | | | | Fix the LoggerSilence to work as described:
| * | | | | Fix the LoggerSilence to work as described:Edouard CHIN2018-10-023-19/+27
| | |_|/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Following the Rails guide which state that a logger needs to include the `ActiveSupport::LoggerSilence` as well as `ActiveSupport::LoggerThreadSafe` modules isn't enough and won't work. Here is a test cases with 3 tests that all fails https://gist.github.com/Edouard-chin/4a72930c2b1eafbbd72a80c66f102010 The problems are the following: 1) The logger needs to call `after_initialize` in order to setup some instance variables. 2) The silence doesn't actually work because the bare ruby Logger `add` method checks for the instance variable `@logger`. We need to override the `add` (like we used to in the ActiveSupport::Logger class). 3) Calling `debug?` `info?` etc... doesn't work as the bare ruby methods will check for the instance variable. Again we need to override this methods (like we used to in the ActiveSupport::Logger class) The LoggerSilence won't work without LoggerThreadSafe, but the later is not public API, the user shouldn't have to include it so I modified to include it automatically. Same for the `after_initialize` method. I find unuintitive to have to call it directly. I modified to instance the variables when the module get included.
* / | | | Bring config_accessor's API document back to its lifeAkira Matsuda2018-10-031-1/+1
|/ / / / | | | | | | | | | | | | the document has been disappeared since the method became private at c2bfe6cbc8cab9caeab418472a1e12a3ed3e75e2
* | | | Merge pull request #34051 from gmcgibbon/module_parent_method_renameRafael Mendonça França2018-10-022-15/+39
|\ \ \ \ | | | | | | | | | | | | | | | Prefix Module#parent, Module#parents, and Module#parent_name with module
| * | | | Fix call sitesGannon McGibbon2018-10-021-2/+2
| | | | |
| * | | | Prefix Module#parent, Module#parents, and Module#parent_name with moduleGannon McGibbon2018-10-021-13/+37
| | | | |