aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
Commit message (Collapse)AuthorAgeFilesLines
...
* | | | | cpu_time and allocations are 0 when JRuby is usedYasuo Honda2018-07-301-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | According to #33449 and #33468, cpu_time and allocations are 0 when JRuby is used. ```ruby $ ruby -v jruby 9.2.1.0-SNAPSHOT (2.5.0) 2018-07-27 13b2df5 Java HotSpot(TM) 64-Bit Server VM 25.181-b13 on 1.8.0_181-b13 [linux-x86_64] $ bundle exec ruby -w -Itest test/log_subscriber_test.rb -n test_event_attributes Run options: -n test_event_attributes --seed 6231 F Failure: SyncLogSubscriberTest#test_event_attributes [test/log_subscriber_test.rb:84]: Expected 0 to be > 0. rails test test/log_subscriber_test.rb:78 Finished in 0.018983s, 52.6791 runs/s, 105.3582 assertions/s. 1 runs, 2 assertions, 1 failures, 0 errors, 0 skips ```
* | | | | Only use CLOCK_PROCESS_CPUTIME_ID if it's definedBart de Water2018-07-291-2/+8
|/ / / / | | | | | | | | | | | | It's not defined on JRuby and unlike monotonic time, concurrent-ruby doesn't have an cross-platform abstraction for this.
* | | | Remove unused `require "active_support/core_ext/regexp"`Ryuta Kamizono2018-07-2912-13/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Ruby 2.4 has native `Regexp#match?`. https://ruby-doc.org/core-2.4.0/Regexp.html#method-i-match-3F Related #32034.
* | | | Work around Performance/EndWith false positiveBart de Water2018-07-281-2/+2
| | | | | | | | | | | | | | | | | | | | Rubocop warns about "Use String#end_with? instead of a regex match anchored to the end of the string", it doesn't seem aware of the $` special variable like Performance/RegexpMatch
* | | | Merge pull request #33441 from bogdanvlviv/remove-rubocop-comments-from-codebaseRyuta Kamizono2018-07-271-1/+1
|\ \ \ \ | | | | | | | | | | Remove Rubocop's comments from Rails code base
| * | | | Fix Rubocop offensebogdanvlviv2018-07-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ``` Offenses: activesupport/lib/active_support/subscriber.rb:91:17: C: Layout/SpaceAroundOperators: Operator = should be surrounded by a single space. event = event_stack.pop ```
* | | | | I cannot spellAaron Patterson2018-07-261-1/+1
| | | | |
* | | | | Add changelog entryAaron Patterson2018-07-261-0/+34
| | | | |
* | | | | fix arity check to use "parameters" for backwards compatAaron Patterson2018-07-261-4/+9
| | | | |
* | | | | Always subscribe to event objects via `AS::Notifications.subscribe`Aaron Patterson2018-07-263-21/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We don't need to have a special subscribe method for objects. The regular `subscribe` method is more expensive than a specialized method, but `subscribe` should not be called frequently. If that turns out to be a hotspot, we can introduce a specialized method. :)
* | | | | Subscribe to event objects via `subscribe`Aaron Patterson2018-07-261-0/+12
| | | | |
* | | | | Subscribe to event objects via `subscribe_event`Aaron Patterson2018-07-263-1/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fanout notifier can send event objects to subscribers now. Also moved `end` lower in the `finish!` method to guarantee that CPU time is shorter than real time.
* | | | | Match the units in `duration` (milliseconds)Aaron Patterson2018-07-261-1/+7
|/ / / /
* | | | Add cpu_time, idle_time, and allocations to EventEileen Uchitelle2018-07-264-4/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Use process clock instead of Time.now This fixes any issues with the system clock changing and also eliminates 2 object allocations per event. * Add start! and finish! methods to the event object so we can record more information * Adds cpu time, idle time, and allocation count for a particular event. Co-authored-by: Aaron Patterson <aaron.patterson@gmail.com>
* | | | Merge pull request #32381 from q-centrix/update-codeclimate-configsRichard Schneeman2018-07-255-22/+12
|\ \ \ \ | | | | | | | | | | Turn on performance based cops
| * | | | Turn on performance based copsDillon Welch2018-07-235-22/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use attr_reader/attr_writer instead of methods method is 12% slower Use flat_map over map.flatten(1) flatten is 66% slower Use hash[]= instead of hash.merge! with single arguments merge! is 166% slower See https://github.com/rails/rails/pull/32337 for more conversation
* | | | | Update with_options.rbDaniel Amireh2018-07-251-1/+1
| | | | | | | | | | | | | | | explicit mapping for enum accepts a Hash not an Array, plus the example is using `.keys` which also exists on hash
* | | | | Merge pull request #33229 from ↵Matthew Draper2018-07-251-1/+1
|\ \ \ \ \ | |/ / / / |/| | | | | | | | | | | | | | albertoalmagro/albertoalmagro/prefer-rails-command-over-bin-rails Prefer rails command over bin/rails
| * | | | Fix typo 'in via'Alberto Almagro2018-07-061-1/+1
| | | | | | | | | | | | | | | | | | | | Substitutes 'in via' for 'by running'
| * | | | Recommend use of rails over bin/railsAlberto Almagro2018-07-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As discussed in #33203 rails command already looks for, and runs, bin/rails if it is present. We were mixing recommendations within guides and USAGE guidelines, in some files we recommended using rails, in others bin/rails and in some cases we even had both options mixed together.
* | | | | e4e1b62 broke `to_param` handling:Edouard CHIN2018-07-122-2/+19
| |/ / / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - There was an issue inside controller tests where order params were not respected, the reason was because we were calling `Hash#to_query` which sorts the results lexicographically. 1e4e1b62 fixed that issue by not using `to_query` but instead a utility function provided by rack. - However with the fix came another issue where it's now no longer possible to do this ``` post :foo, params: { user: User.first } # Prior to the patch the controller will receive { "user" => "1" } # Whereas now you get { "user": "#<User: ...>" } ``` The fix in this PR is to modify `Hash#to_query` to sort only when it doesn't contain an array structure that looks something like "bar[]" Ref https://github.com/rails/rails/pull/33341#issuecomment-404039396
* | | | added tests for assert_no_difference with multiple expressionslxxxvi2018-07-082-0/+28
|/ / /
* | | A Class is a Module so we remove one conditionalRafael Mendonça França2018-07-041-1/+1
| | |
* | | Merge pull request #33289 from Edouard-chin/ec-lazy-load-hooksRafael França2018-07-042-1/+54
|\ \ \ | | | | | | | | Use class_eval or instance_eval when triggering lazy load hooks
| * | | Use class_eval or instance_eval when triggering lazy load hooks:Edouard CHIN2018-07-032-1/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - When lazy load hooks were triggered we were using `Object.instance_eval` which evaluates the block in the context of the class being passed. Most of the time that class was a `Class`. If one wants to define a instance method on the class then it wasn't possible. ```ruby class A; end; A.instance_eval do def foo puts 'bar' end end A.new.foo #> NoMethodError: undefined method `foo` A.foo #> bar ``` - This PR checks what object is passed when triggering the hooks and either call `class_eval` or `instance_eval`. My rational and assumptions being that if an instance of a class is passed, then the blocks needs to evaluate in the context of that instance (i.e. defining a method should only define it on that instance). On the other hand, if a Class or Module is passed when triggering hooks, then defining a method should define it on the class itself - #32776 Pushed me to introduce this change
* | | | Refactor #33254.Kasper Timm Hansen2018-07-013-29/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Firstly, increment and decrement shouldn't care about the particulars of key expiry. They should only know that they have to pass that responsibility on to somewhere else. Secondly, it moves the key normalization back inside the instrumentation like it was originally. I think that matches the original design intention or at the very least it lets users catch haywire key truncation. Thirdly, it moves the changelog entry to the top of the file, where new entries go. I couldn't understand what the entry was saying so I tried to rewrite it.
* | | | Fix Cache :redis_store increment/decrement ttl check and add more tests.Jason Lee2018-06-302-6/+22
| | | |
* | | | Add :expires_in option support for RedisCacheStore increment/decrement method.Jason Lee2018-06-293-2/+57
| | | |
* | | | Add tests for duration multiplication and divisionEugene Kenny2018-06-251-0/+12
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When multiplying or dividing a duration by a scalar, it's tempting to operate directly on the duration's value in seconds and recompute the parts from the result. However this loses information, as there are multiple combinations of parts that map to any given number of seconds (e.g. `2.weeks` or `336.hours`). This is especially problematic when dealing with durations on the scale of months or years, as converting an exact number of seconds to one of those intervals and then using the resulting duration to modify a date will give the wrong result.
* | | Merge pull request #33106 from marcandre/datecalcRafael Mendonça França2018-06-111-15/+12
|\ \ \ | | | | | | | | | | | | Improve some DateAndTime calculations
| * | | Use fetch for better error handlingMarc-Andre Lafortune2018-06-091-2/+2
| | | |
| * | | Use same weekday correspondance as Date#wday.Marc-Andre Lafortune2018-06-091-13/+10
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | DeepCover revealed that most of these `wday != 0 ? wday - 1 : 6` were not entirely covered, i.e. the case of `wday == 0` was not tested: https://deep-cover.github.io/rails-cover/activesupport/activesupport/lib/active_support/core_ext/date_and_time/calculations.rb.html#L351 There's actually no valid reason to consider Sunday a special case, so this commit simply reajusts the values used for calculations.
* | | Merge pull request #33078 from bogdanvlviv/add-remove-requireRyuta Kamizono2018-06-095-13/+5
|\ \ \ | | | | | | | | Add/Remove `require`
| * | | Add missing `require`bogdanvlviv2018-06-072-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | `activesupport/test/logger_test.rb` requires `tmpdir`. `activesupport/test/multibyte_test_helpers.rb` requires `filutils`, `open-uri`, and `tmpdir`.
| * | | Remove unused `require`bogdanvlviv2018-06-073-13/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - `activesupport/multibyte_normalization_conformance_test.rb` `fileutils`, `tmpdir`, and `open-uri` are unused since c245ca30f248367e07d5d831195b12c93a1e3137, c245ca30f248367e07d5d831195b12c93a1e3137, and 7d7c2d13ba896dd8b58fe91d2fe0c4fc588069ca in accordance. - `activesupport/test/multibyte_conformance_test.rb` `tmpdir`, and `open-uri` are unused since c245ca30f248367e07d5d831195b12c93a1e3137, and 7d7c2d13ba896dd8b58fe91d2fe0c4fc588069ca in accordance. Remove using of `fileutils` since c245ca30f248367e07d5d831195b12c93a1e3137. - `activesupport/test/multibyte_grapheme_break_conformance_test.rb` `fileutils`, `tmpdir`, and `open-uri` are unused since c245ca30f248367e07d5d831195b12c93a1e3137, c245ca30f248367e07d5d831195b12c93a1e3137, and 7d7c2d13ba896dd8b58fe91d2fe0c4fc588069ca in accordance.
* | | | Merge pull request #33087 from bogdanvlviv/document-CompareWithRangeRafael França2018-06-081-1/+1
|\ \ \ \ | | | | | | | | | | Add `ActiveSupport::CompareWithRange` to API docs
| * | | | Add `ActiveSupport::CompareWithRange` to API docsbogdanvlviv2018-06-071-1/+1
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since it is documented in the guides http://edgeguides.rubyonrails.org/active_support_core_extensions.html#include-questionmark-and-cover-questionmark we can add it to API docs http://edgeapi.rubyonrails.org too. [ci skip]
* / / / Remove extra `include ActiveSupport::Testing::MethodCallAssertions`bogdanvlviv2018-06-081-3/+0
|/ / / | | | | | | | | | It includes via `require "abstract_unit"`.
* | | Don't expose `Enumerable#_original_sum_with_required_identity` which is ↵yuuji.yaginuma2018-06-041-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | internal API [ci skip] `:nodoc:` is specified, but unfortunately, it is exposed in the API doc. http://edgeapi.rubyonrails.org/classes/Enumerable.html#method-i-_original_sum_with_required_identity If the method of the `alias` destination is public, the specification of `:nodoc:` does not seem to work.
* | | [ci skip] "brethen" is misspelled and unclearMichael Gee2018-05-311-1/+1
| | |
* | | Merge pull request #33020 from joshpencheon/time_zone_frac_microsecondsRafael França2018-05-302-2/+17
|\ \ \ | | | | | | | | Align Time.zone.at method signature with that of Time::at
| * | | Allow Time.zone.at to receive a second argumentJosh Pencheon2018-05-302-2/+17
| | | | | | | | | | | | | | | | For parity with Ruby's Time::at
* | | | Remove unused `require "active_support/file_update_checker"`yuuji.yaginuma2018-05-301-1/+0
|/ / / | | | | | | | | | This is unnecessary since #22269.
* | | Improve grammar for DateAndTime before? and after? calculations [ci skip]Aaron Sumner2018-05-241-2/+2
| | |
* | | Merge pull request #32822 from lxxxvi/improved_error_message_in_assert_changesRafael França2018-05-222-2/+4
|\ \ \ | | | | | | | | Clearer error message in assert_changes
| * | | Clearer error message in assert_changeslxxxvi2018-05-052-2/+4
| | | | | | | | | | | | | | | | When `to:` is passed to `assert_changes`, it now prints the well-known `"Expected: x\n Actual: y"` message. Before, the message only contained the actual value.
* | | | Merge pull request #32851 from yskkin/doc_require_dependencyRafael França2018-05-221-0/+4
|\ \ \ \ | | | | | | | | | | Document require_dependency [ci skip]
| * | | | Document require_dependency [ci skip]Yoshiyuki Kinjo2018-05-091-0/+4
| | | | |
* | | | | add CHANGELOG/Docutilum2018-05-221-0/+11
| | | | |
* | | | | Allow Range#=== and Range#cover? on Rangeutilum2018-05-223-23/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ruby/ruby@989e07c features switching `Range#===` to use internal `r_cover_p` instead of rubyland `include?`. This breaks expected behavior of `ActiveSupport::CoreExt::Range` documented since at least 8b67a02. This patch adds overrides on `Range#cover?` and `Range#===` and places all three in a single module, `CompareWithRange`. *Requiring core_ext/range/include_range now causes a deprecation warnning*