- 30 5月, 2017 3 次提交
-
-
由 Jon Moss 提交于
[ci skip]
-
由 Ryuta Kamizono 提交于
-
由 David Heinemeier Hansson 提交于
* Allow a default value to be declared for class_attribute * Convert to using class_attribute default rather than explicit setter * Removed instance_accessor option by mistake * False is a valid default value * Documentation
-
- 28 5月, 2017 2 次提交
-
-
由 Kasper Timm Hansen 提交于
If users added an attribute or otherwise changed a CurrentAttributes subclass they'd see exceptions on the next page load. Because `ActiveSupport::CurrentAttributes.current_instances` would keep references to the old instances from the previous request. We can fix this by clearing out the `current_attributes` before we unload constants. Then any change to the model can be autoloaded again since its slot isn't taken by an old instance. We'll still have to call reset before we clear so external collaborators, like Time.zone, won't linger with their current value throughout other code.
-
由 Kasper Timm Hansen 提交于
Since we're generating a key through the class name we can combine the two Thread.current calls into a single hash version.
-
- 27 5月, 2017 3 次提交
-
-
由 Kasper Timm Hansen 提交于
`find` raises when it can't find a record, so we'll never reach the else. Switch to `find_by` which returns nil when no record can be found.
-
由 Kasper Timm Hansen 提交于
-
由 David Heinemeier Hansson 提交于
* Add ActiveSupport::CurrentAttributes to provide a thread-isolated attributes singleton * Need to require first * Move stubs into test namespace. Thus they won't conflict with other Current and Person stubs. * End of the line for you, whitespace! * Support super in attribute methods. Define instance level accessors in an included module such that `super` in an overriden accessor works, akin to Active Model. * Spare users the manual require. Follow the example of concerns, autoload in the top level Active Support file. * Add bidelegation support * Rename #expose to #set. Simpler, clearer * Automatically reset every instance. Skips the need for users to actively embed something that resets their CurrentAttributes instances. * Fix test name; add tangible name value when blank. * Try to ensure we run after a request as well. * Delegate all missing methods to the instance This allows regular `delegate` to serve, so we don't need bidelegate. * Properly test resetting after execution cycle. Also remove the stale puts debugging. * Update documentation to match new autoreset
-
- 26 5月, 2017 1 次提交
-
-
由 yuuji.yaginuma 提交于
`AlsoDoingNothingTest` was added in cf9be897. It seems that it added to confirm that the test works in the child class of `ActiveSupport::TestCase`. But now basically use `ActiveSupport::TestCase` in test, so I think it is unnecessary.
-
- 24 5月, 2017 1 次提交
-
-
由 Koichi ITO 提交于
-
- 23 5月, 2017 1 次提交
-
-
由 bogdanvlviv 提交于
".. with __dir__ we can restore order in the Universe." - by @fxn Related to 5b8738c2
-
- 20 5月, 2017 2 次提交
-
-
由 Andrew White 提交于
Previously calculations where the scalar is first would be converted to a duration of seconds but this causes issues with dates being converted to times, e.g: Time.zone = "Beijing" # => Asia/Shanghai date = Date.civil(2017, 5, 20) # => Mon, 20 May 2017 2 * 1.day # => 172800 seconds date + 2 * 1.day # => Mon, 22 May 2017 00:00:00 CST +08:00 Now the `ActiveSupport::Duration::Scalar` calculation methods will try to maintain the part structure of the duration where possible, e.g: Time.zone = "Beijing" # => Asia/Shanghai date = Date.civil(2017, 5, 20) # => Mon, 20 May 2017 2 * 1.day # => 2 days date + 2 * 1.day # => Mon, 22 May 2017 Fixes #29160, #28970.
-
由 David Heinemeier Hansson 提交于
-
- 19 5月, 2017 4 次提交
-
-
由 David Heinemeier Hansson 提交于
This retains the existing behavior of ActiveSupport::Cache.expand_cache_key (as used by etaging) where the cache key includes the version.
-
由 Eilis Hamilton 提交于
Previously apply_inflections would only use the :en uncountables rather then the ones for the locale that was passed to pluralize or singularize. This changes apply_inflections to take a locale which it will use to find the uncountables.
-
由 Ryuta Kamizono 提交于
* Fix indentation. * Add backticks.
-
由 David Heinemeier Hansson 提交于
-
- 15 5月, 2017 3 次提交
-
-
由 Michael Coyne 提交于
-
由 Michael Coyne 提交于
When MessageEncryptor tries to +decrypt_and_verify+ ciphertexts generated in a different mode (such CBC-HMAC), the +auth_tag+ may be +nil+ and must explicitly check for it. See the discussion here: https://github.com/rails/rails/pull/28132#discussion_r116388462
-
由 Eugene Kenny 提交于
Some cache backends support the `unless_exist` option, which tells them not to overwrite an existing entry. The local cache currently always stores the new value, even though the backend may have rejected it. Since we can't tell which value will end up in the backend cache, we should delete the key from the local cache, so that the next read for that key will go to the backend and pick up the correct value.
-
- 14 5月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
`display_deprecation_warning_for_false_terminator` was removed since 3a25cdca.
-
- 11 5月, 2017 1 次提交
-
-
由 Peter McCracken 提交于
-
- 07 5月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
-
- 05 5月, 2017 2 次提交
-
-
由 T.J. Schuck 提交于
The method is named `delegate_missing_to`, not `delegate_to_missing`
-
由 T.J. Schuck 提交于
* Fix rdoc code formatting — `tt`, not backticks * Fix/simplify sentence grammar — should at least just be “and the like”, not “likes”, but this is just general tightening up. * Add note that delegated methods must be public. Tested here: https://github.com/rails/rails/blob/7ff5ccae94ce2aff76b5f8a31a28e305a047d642/activesupport/test/core_ext/module_test.rb#L359-L365 * Simplify example code for delegate_missing_to. The example had complexity that wasn’t necessary for demonstrating `delegate_missing_to`. This gets rid of a bunch of cruft so the example is more obvious about what’s going on regarding the feature itself. [ci skip]
-
- 30 4月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
* Remove trailing spaces. * Add backticks around method and command. * Fix indentation.
-
- 29 4月, 2017 2 次提交
-
-
由 Ryuta Kamizono 提交于
-
由 Eugene Kenny 提交于
https://github.com/rails/rails/commit/505537082849d912e8e29819655b80a573e93c0c added a call to `remove_possible_method`, but didn't require the file that defines it.
-
- 25 4月, 2017 1 次提交
-
-
由 Eugene Kenny 提交于
The Enumerator#size method was introduced in Ruby 2.0. These tests were added when Rails 4.1 was current, and Ruby 1.9.3 was still supported. Since Rails 5 only Ruby >= 2.2.2 is supported, so the checks are no longer necessary.
-
- 22 4月, 2017 1 次提交
-
-
由 Ryuta Kamizono 提交于
Follow up of 03d3f036. Some of `respond_to?` were replaced to `respond_to_missing?` in 03d3f036. But the visibility is still public. It should be private.
-
- 21 4月, 2017 2 次提交
-
-
由 Jon Moss 提交于
[ci skip]
-
由 Josh Nussbaum 提交于
-
- 20 4月, 2017 2 次提交
-
-
由 Marion Bouguet 提交于
Since 3aee9126, this class hasn't inherited from Array.
-
由 Willem van Bergen 提交于
Send deprecation horizon and gem name as arguments to deprecation heavier handler, and make sure they are used for the ActiveSupport::Notifications message.
-
- 19 4月, 2017 2 次提交
-
-
由 T.J. Schuck 提交于
If you just try to use `ActiveSupport::Testing::TimeHelpers` standalone by requiring `active_support/testing/time_helpers`, you currently get an error: `NoMethodError: undefined method `change' for 2017-12-14 01:04:44 -0500:Time` 9f6e82ee added a dependency on `AS::Time` by using `AS::Time#change`. Here's a script to reproduce the error: ```ruby require "bundler/inline" gemfile(true) do source "https://rubygems.org" gem "activesupport", github: "rails/rails" end require "active_support/testing/time_helpers" require "minitest/autorun" class BugTest < Minitest::Test include ActiveSupport::Testing::TimeHelpers def test_stuff travel_to Time.new(2017, 12, 14, 01, 04, 44) do assert true end end end ``` It currently fails for all 5.x.x versions and master. Ideally, this would be backported to `5-0-stable` and `5-1-stable` as well.
-
由 Rafael Mendonça França 提交于
This reverts commit b86631d9, reversing changes made to 8776a713. ActiveSupport::Notifications is loaded using autoload that is defined by the top level file of `active_support`. All the frameworks of Rails requires the top level files before using any of the others files inside the framework because the top level file is what setup the autoload hooks and require the common dependencies.
-
- 18 4月, 2017 4 次提交
-
-
由 Fumiaki MATSUSHIMA 提交于
If we require 'active_support/core_ext/enumerable' on Ruby 2.4, we'll see following warning because `Enumerable#sum` and `Array#sum` are added in Ruby 2.4. ``` rails/rails/activesupport/lib/active_support/core_ext/enumerable.rb:20: warning: method redefined; discarding old sum ``` The minimal way to fix the warning is `alias sum sum`. ``` $ ruby -v ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux] $ ruby -w -e "def a; end; def a; end" -e:1: warning: method redefined; discarding old a -e:1: warning: previous definition of a was here $ ruby -w -e "def a; end; alias a a; def a; end" ``` But this behavior is not intended. (@amatsuda was told by @ko1) So we should use `alias` as a meaningful way. Ruby 2.4's `sum` (`orig_sum`) assumes an `identity` is `0` when we omit `identity` so we can delegate to `orig_sum` with explicit `identity` only. In a strict sense, we can detect `identity` by check instance's class but we don't care at this time about that because calling `Enumerable#sum` is rare. In many cases, we will call `Array#sum`.
-
由 Jon Moss 提交于
[ci skip]
-
由 Ken Mayer 提交于
There's a difference in the results between `Date#to_time(:local)` and `Date#in_time_zone` but it is subtle and can confuse users (like me :-).
-
由 T.J. Schuck 提交于
Right now, if you install the current release version of Active Support (5.0.2) and try to use its cache implementation standalone by requiring `active_support/cache`, it crashes with `NameError: uninitialized constant ActiveSupport::Notifications`. `AS::Notifications` is used in `cache.rb` down around [line 555](https://github.com/rails/rails/blob/8776a7139757d0b264785c774d4e7f37d4bc1ac7/activesupport/lib/active_support/cache.rb#L555). Here's a quick repro script: ```ruby require "bundler/inline" gemfile(true) do source "https://rubygems.org" gem "activesupport", "5.0.2" end require "active_support/cache" cache_store = ActiveSupport::Cache::MemoryStore.new cache_store.write('test', 'okay') puts cache_store.read('test') ``` However, any version _newer_ than 5.0.2 passes. This is because [this commit](https://github.com/rails/rails/commit/75924c4517c8f87712d3f59c11f10152ed57b9d8) inadvertently included `AS::Notifications` into `AS::Cache` (thus fixing the issue) by mixing [`AS::Deprecation` into `AS::Duration`](https://github.com/rails/rails/blob/75924c4517c8f87712d3f59c11f10152ed57b9d8/activesupport/lib/active_support/duration.rb#L4), giving you a nice require chain of [`Cache` including `Time`][1] [including `Duration`][2] [including `Deprecation`][3] [including `Behaviors`][4] [including `Notifications`][5]. Phew. Aside from being not very explicit, the fact that the fixing is specifically done by `AS::Deprecation` means that this fix is probably only temporary (until the deprecation is removed). This PR just makes the inclusion explicit to future-proof against this breakage. (Ideally, this would also be backported to `5-0-stable` to get picked up in any subsequent point release.) See also: https://github.com/rails/rails/pull/14667 [1]: https://github.com/rails/rails/blob/75924c4517c8f87712d3f59c11f10152ed57b9d8/activesupport/lib/active_support/cache.rb#L6 [2]: https://github.com/rails/rails/blob/75924c4517c8f87712d3f59c11f10152ed57b9d8/activesupport/lib/active_support/time.rb#L2 [3]: https://github.com/rails/rails/blob/75924c4517c8f87712d3f59c11f10152ed57b9d8/activesupport/lib/active_support/duration.rb#L4 [4]: https://github.com/rails/rails/blob/75924c4517c8f87712d3f59c11f10152ed57b9d8/activesupport/lib/active_support/deprecation.rb#L16 [5]: https://github.com/rails/rails/blob/75924c4517c8f87712d3f59c11f10152ed57b9d8/activesupport/lib/active_support/deprecation/behaviors.rb#L1
-