| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|\ \ \ \ \
| |_|/ / /
|/| | | | |
Follow up #34754
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
- Fix a few deprecation warnings
- Remove testing of `Hash#slice`
- Imporve test of `Hash#slice!`
- Remove mention about `Hash#slice` from the guide
|
|/ / / /
| | | |
| | | |
| | | |
| | | |
| | | | |
since Ruby 2.5
https://bugs.ruby-lang.org/issues/14133
|
| | | |
| | | |
| | | |
| | | | |
Follow up #34761.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
`Hash#transform_keys!`
Since Rails 6 requires Ruby 2.5.
https://github.com/ruby/ruby/blob/ruby_2_5/NEWS
Follow up #34754.
|
|/ / /
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
* Extend documentation of `ActiveSupport::Notifications.subscribe`
Add mention that a block with only one argument passed to the method
will yield an event object.
Related to #33451
* Emphasize that `SubscribeEventObjects` is a test class by adding suffix `Test`
|
| | |
| | |
| | |
| | | |
There was no test without an alternate method name is given.
|
|/ /
| |
| |
| | |
Ref https://github.com/rails/rails/commit/59ff1ba30d9f4d34b4d478104cc3f453e553c67a#diff-38fb97fba84b1ef0f311c4110a597c44R35
|
| |
| |
| |
| |
| |
| |
| |
| | |
Before #33325, `deprecate` works for non-exist methods.
This is necessary, for example, if want to deprecate dynamically defined
methods like attributes methods.
Fixes #34646
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
If the same block is included multiple times, we no longer raise an exception
or overwrite the included block instance variable.
Fixes #14802.
[Mark J. Titorenko + Vlad Bokov]
|
|\ \
| | |
| | | |
`atomic_write`: Ensure correct permission when `tmpdir` is the same as `dirname`.
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This fixes following warnings:
```
test/dependencies_test.rb:287: warning: possibly useless use of :: in void context
test/dependencies_test.rb:300: warning: possibly useless use of a constant in void context
```
|
| |/
|/|
| |
| | |
Closes #34062
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| | |
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.
|
|\ \
| | |
| | | |
Implement AR#inspect using ParameterFilter
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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
|
| | | |
|
| | |
| | |
| | |
| | | |
in favor of `array.flatten.pack("U*")` and `string.scan(/\X/).map(&:codepoints)`, respectively.
|
| | |
| | |
| | |
| | |
| | |
| | | |
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.
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
- 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
|
| | |
|
| | |
|
| |
| |
| |
| | |
Use String methods directly instead.
|
| |
| |
| |
| |
| | |
Check that options passed to the to_json are passed to all objects that
respond to as_json.
|
| |
| |
| |
| | |
ActiveSupport::ParameterFilter
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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
|
| | |
|
|\ \
| | |
| | | |
Fix the LoggerSilence to work as described:
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
- 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.
|
|/ / |
|
|\ \
| | |
| | |
| | | |
Prefix Module#parent, Module#parents, and Module#parent_name with module
|
| | | |
|
|/ /
| |
| |
| |
| |
| |
| |
| | |
- I found this weird that the LoggerSilence wasn't using the
`ActiveSupport` namespace (AFAIK all other classes have it).
This PR deprecate the use of `LoggerSilence` for
`ActiveSupport::LoggerSilence` instead.
|
|\ \
| |/
|/| |
Add deprecation warning when String#first and String#last receive neg…
|
| |
| |
| |
| |
| |
| | |
integers
[Gannon McGibbon + Eric Turner]
|
| | |
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Since Rails 6.0 will support Ruby 2.4.1 or higher
`# frozen_string_literal: true` magic comment is enough to make string object frozen.
This magic comment is enabled by `Style/FrozenStringLiteralComment` cop.
* Exclude these files not to auto correct false positive `Regexp#freeze`
- 'actionpack/lib/action_dispatch/journey/router/utils.rb'
- 'activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb'
It has been fixed by https://github.com/rubocop-hq/rubocop/pull/6333
Once the newer version of RuboCop released and available at Code Climate these exclude entries should be removed.
* Replace `String#freeze` with `String#-@` manually if explicit frozen string objects are required
- 'actionpack/test/controller/test_case_test.rb'
- 'activemodel/test/cases/type/string_test.rb'
- 'activesupport/lib/active_support/core_ext/string/strip.rb'
- 'activesupport/test/core_ext/string_ext_test.rb'
- 'railties/test/generators/actions_test.rb'
|
| |
|
|
|
|
|
|
|
|
|
|
| |
* Handle more unsafe String methods
* Fix codeclimate issue
* Revert stylistic change
[Janosch Müller + Rafael Mendonça França]
|
| |
|
|\
| |
| | |
Remove private def
|
| | |
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In Ruby 2.3 or later, `String#+@` is available and `+@` is faster than `dup`.
```ruby
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "benchmark-ips"
end
Benchmark.ips do |x|
x.report('+@') { +"" }
x.report('dup') { "".dup }
x.compare!
end
```
```
$ ruby -v benchmark.rb
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
Warming up --------------------------------------
+@ 282.289k i/100ms
dup 187.638k i/100ms
Calculating -------------------------------------
+@ 6.775M (± 3.6%) i/s - 33.875M in 5.006253s
dup 3.320M (± 2.2%) i/s - 16.700M in 5.032125s
Comparison:
+@: 6775299.3 i/s
dup: 3320400.7 i/s - 2.04x slower
```
|
|\
| |
| |
| | |
TaggedLogging to return a new logger instance
|
| | |
|
| | |
|