aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
Commit message (Collapse)AuthorAgeFilesLines
...
* | | Refactor calculating beginning_of_quarter and end_of_quarter (#34927)Krzysztof Rybka2019-01-141-2/+2
| | | | | | | | | | | | | | | | | | | | | * Calculate first month of quarter instead of finding * Calculate last month of quarter instead of finding [Krzysztof Rybka + Rafael Mendonça França]
* | | Fix safe_constantize to not raise a LoadError.Keenan Brock2019-01-094-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ### Summary There was an issues when using `safe_constantize` on a string that has the wrong case. File `em.rb` defines `EM`. `"Em".safe_constantize` causes a little confusion with the autoloader. The autoloader finds file "em.rb", expecting it to define `Em`, but `Em` is not defined. The autoloader raises a `LoadError`, which is good, But `safe_constantize` is defined to return `nil` when a class is not found. ### Before ``` "Em".safe_constantize LoadError: Unable to autoload constant Em, \ expected rails/activesupport/test/autoloading_fixtures/em.rb to define it ``` ### After ``` "Em".safe_constantize # => nil ```
* | | Merge pull request #34899 from rails/speed-up-stepAaron Patterson2019-01-091-1/+4
|\ \ \ | | | | | | | | Duration#coerce should always return a Scalar
| * | | Duration#coerce should always return a ScalarAaron Patterson2019-01-081-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | This speeds up Range.new(x, y).step(Duration).each { ... } Fixes #34888
* | | | Enable `Lint/UselessAssignment` cop to avoid unused variable warnings (#34904)Ryuta Kamizono2019-01-091-1/+1
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Enable `Lint/UselessAssignment` cop to avoid unused variable warnings Since we've addressed the warning "assigned but unused variable" frequently. 370537de05092aeea552146b42042833212a1acc 3040446cece8e7a6d9e29219e636e13f180a1e03 5ed618e192e9788094bd92c51255dda1c4fd0eae 76ebafe594fc23abc3764acc7a3758ca473799e5 And also, I've found the unused args in c1b14ad which raises no warnings by the cop, it shows the value of the cop.
* | | Revert "Revert "Merge pull request #34387 from ↵Kasper Timm Hansen2019-01-081-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | yhirano55/rails_info_properties_json"" I reverted the wrong commit. Damn it. This reverts commit f66a977fc7ae30d2a07124ad91924c4ee638a703.
* | | Revert "Merge pull request #34387 from yhirano55/rails_info_properties_json"Kasper Timm Hansen2019-01-081-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We had a discussion on the Core team and we don't want to expose this information as a JSON endpoint and not by default. It doesn't make sense to expose this JSON locally and this controller is only accessible in dev, so the proposed access from a production app seems off. This reverts commit 8eaffe7e89719ac62ff29c2e4208cfbeb1cd1c38, reversing changes made to b6e4305c3bca4c673996d0af9db0f4cfbf50215e.
* | | Merge pull request #34700 from gmcgibbon/fetch_multi_key_orderRafael França2019-01-073-10/+24
|\ \ \ | | | | | | | | Preserve key order of #fetch_multi
| * | | Preserve key order passed to ActiveSupport::CacheStore#fetch_multiGannon McGibbon2018-12-273-10/+24
| | | | | | | | | | | | | | | | | | | | | | | | fetch_multi(*names) now returns its results in the same order as the `*names` requested, rather than returning cache hits followed by cache misses.
* | | | Clarify `delegate_missing_to` [ci skip]bogdanvlviv2019-01-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since #34864 removed explicit receiver to clarify the purpose of `delegate_missing_to`, I think it will be better to do the same a few lines above to easier figure out that `delegate_missing_to` defines `method_missing`, `respond_to_missing?` when comparing these examples.
* | | | Clarify benefit of `delegate_missing_to`Michael Gee2019-01-041-1/+1
| | | | | | | | | | | | Removing the explicit receiver clarifies the purpose of `delegate_missing_to`.
* | | | Fix examples in ActiveSupport::LogSubscriber docsGannon McGibbon2019-01-011-3/+3
| | | | | | | | | | | | | | | | [ci skip]
* | | | Merge pull request #34707 from xlts/update-notifications-docsGannon McGibbon2018-12-312-9/+35
|\ \ \ \ | | | | | | | | | | Add examples describing error handling in ActiveSupport::Notification…
| * | | | Add examples describing error handling in ActiveSupport::Notifications and ↵Mariusz Hausenplas2018-12-142-9/+35
| | | | | | | | | | | | | | | | | | | | ActiveSupport::LogSubscriber documentation files
* | | | | Bump license years for 2019Arun Agrawal2018-12-312-2/+2
| | | | |
* | | | | Tweak test nameGeorge Claghorn2018-12-301-1/+1
| | | | |
* | | | | Make Active Storage blob keys lowercaseJulik Tarkhanov2018-12-302-3/+43
| | | | | | | | | | | | | | | Accommodate case-insensitive filesystems and database collations.
* | | | | No need to handle if FrozenError is availableYasuo Honda2018-12-232-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rails 6 requires Ruby 2.5, which introduces `FrozenError` https://docs.ruby-lang.org/en/2.5.0/NEWS.html Related to #31520
* | | | | Fixes `warning: mismatched indentations at 'rescue' with 'def' at 15`.utilum2018-12-211-2/+2
| | | | | | | | | | | | | | | | | | | | See https://travis-ci.org/rails/rails/jobs/470890129#L2361
* | | | | Add missing require for `String#to_d`yuuji.yaginuma2018-12-211-0/+1
| | | | |
* | | | | Merge pull request #34767 from y-yagi/fix_convert_string_to_bigdecimalYuji Yaginuma2018-12-211-5/+1
|\ \ \ \ \ | | | | | | | | | | | | Use BigDecimal provided methods to convert String to BigDecimal
| * | | | | Use BigDecimal provided methods to convert String to BigDecimalyuuji.yaginuma2018-12-211-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `String#to_d` does not raise an exception if an invalid value is specified. So can remove exception handling. ``` $ bundle exec ruby -v -rbigdecimal -rbigdecimal/util -e 'p "123,003".to_d' ruby 2.6.0dev (2018-12-21 trunk 66474) [x86_64-linux] 0.123e3 ```
* | | | | | Merge pull request #34764 from kamipo/avoid_redundant_beginRyuta Kamizono2018-12-219-178/+153
|\ \ \ \ \ \ | | | | | | | | | | | | | | Enable `Style/RedundantBegin` cop to avoid newly adding redundant begin block
| * | | | | | Enable `Style/RedundantBegin` cop to avoid newly adding redundant begin blockRyuta Kamizono2018-12-219-178/+153
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently we sometimes find a redundant begin block in code review (e.g. https://github.com/rails/rails/pull/33604#discussion_r209784205). I'd like to enable `Style/RedundantBegin` cop to avoid that, since rescue/else/ensure are allowed inside do/end blocks in Ruby 2.5 (https://bugs.ruby-lang.org/issues/12906), so we'd probably meets with that situation than before.
* | | | | | | Merge pull request #34769 from elebow/module-delegate-to-docstringRyuta Kamizono2018-12-211-1/+1
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | Module.delegate rdoc update to clarify :to parameter [ci skip]
| * | | | | | | Clarify the :to parameter of delegateEddie Lebow2018-12-201-1/+1
| | | | | | | |
* | | | | | | | Merge pull request #33822 from y-yagi/do_not_check_parents_dor_directoriesYuji Yaginuma2018-12-212-2/+50
|\ \ \ \ \ \ \ \ | |/ / / / / / / |/| | | | | | | Do no watch parent directory of `dirs`
| * | | | | | | Do not add parent directory to file system monitoringyuuji.yaginuma2018-12-182-2/+50
| | |_|/ / / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `EventedFileUpdateChecker` will search the parent directory if the specified directory does not exist. Since `test/mailers/previews` is included in the watch target by default, if there is no test directory (e.g. using `rspec`), the Rails root directory will be included in the watch target. ``` $ rails new app $ cd app $ ./bin/rails r "p Rails.application.reloaders.last.send(:directories_to_watch).include?(Rails.root)" false $ rm -rf test $ ./bin/rails r "p Rails.application.reloaders.last.send(:directories_to_watch).include?(Rails.root)" true ``` This causes `node_modules` to be included in watch target. Adding parent directories to watch target may include unexpected directories. In order to avoid this, fixed that parents of nonexistent directories are not added to the watch targets, instead checking that the directory exists when checking changes. Related to #32700. [Matthew Draper & Yuji Yaginuma]
* | | | | | | Add test for `travel_to` with time zoneyuuji.yaginuma2018-12-211-0/+17
| |_|/ / / / |/| | | | | | | | | | | | | | | | | This is a regression test for #34751.
* | | | | | Merge pull request #34762 from bogdanvlviv/fix-a-few-deprecation-warningsKasper Timm Hansen2018-12-204-31/+9
|\ \ \ \ \ \ | |_|/ / / / |/| | | | | Follow up #34754
| * | | | | Follow up #34754bogdanvlviv2018-12-204-31/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Fix a few deprecation warnings - Remove testing of `Hash#slice` - Imporve test of `Hash#slice!` - Remove mention about `Hash#slice` from the guide
* | | | | | Module#{define_method,alias_method,undef_method,remove_method} become public ↵Ryuta Kamizono2018-12-213-9/+9
|/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | since Ruby 2.5 https://bugs.ruby-lang.org/issues/14133
* | | | | Remove remaining tests for `Hash#transform_keys` and `Hash#transform_keys!`Ryuta Kamizono2018-12-211-27/+0
| | | | | | | | | | | | | | | | | | | | Follow up #34761.
* | | | | Use native `Array#append`, `Array#prepend`, `Hash#transform_keys`, and ↵Ryuta Kamizono2018-12-206-108/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `Hash#transform_keys!` Since Rails 6 requires Ruby 2.5. https://github.com/ruby/ruby/blob/ruby_2_5/NEWS Follow up #34754.
* | | | | Require Ruby 2.5 for Rails 6.Kasper Timm Hansen2018-12-194-34/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Generally followed the pattern for https://github.com/rails/rails/pull/32034 * Removes needless CI configs for 2.4 * Targets 2.5 in rubocop * Updates existing CHANGELOG entries for fewer merge conflicts * Removes Hash#slice extension as that's inlined on Ruby 2.5. * Removes the need for send on define_method in MethodCallAssertions.
* | | | | Add option to set parallel test worker count to the physical core count of ↵Bogdan2018-12-181-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the machine (#34735) * Add option to set parallel test worker count to the physical core count of the machine Also, use the physical core count of the machine as the default number of workers, and generate the `test_helper.rb` file with `parallelize(workers: :number_of_processors)` Closes #34734 * Ensure that we always test parallel testing Since #34734 we decided to use the physical core count of the machine as the default number of workers in the parallel testing, we need to ensure that some tests use at least 2 workers because we could run those tests on VM that has only 1 physical core. It also fixes tests failures on the CI since Travis server we are using has only one physical core. See https://travis-ci.org/rails/rails/jobs/469281088#L2352
* | | | | Extend documentation of `ActiveSupport::Notifications.subscribe` (#34721)Bogdan2018-12-172-2/+9
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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`
* | | | Test ActiveSupport::Deprecation.deprecate_methodsYosuke Kabuto2018-12-141-0/+7
| | | | | | | | | | | | | | | | There was no test without an alternate method name is given.
* | | | Enable `Layout/SpaceAfterSemicolon` cop to avoid newly adding odd spacingRyuta Kamizono2018-12-131-1/+1
|/ / / | | | | | | | | | Ref https://github.com/rails/rails/commit/59ff1ba30d9f4d34b4d478104cc3f453e553c67a#diff-38fb97fba84b1ef0f311c4110a597c44R35
* | | Merge pull request #34648 from y-yagi/fixes_34646Yuji Yaginuma2018-12-122-14/+31
|\ \ \ | | | | | | | | Make `deprecate` work for non-exists methods
| * | | Make `deprecate` work for non-exists methodsyuuji.yaginuma2018-12-072-14/+31
| | |/ | |/| | | | | | | | | | | | | | | | | | | 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
* / | Upgrade Rubocop to 0.61.1 and fix offensesVinicius Stock2018-12-102-28/+29
|/ /
* | Another Ruby 2.6 BigDecimal compatibility issueutilum2018-12-041-1/+1
| | | | | | | | | | | | | | | | | | This patch modifies XmlMini::Parsing["decimal"] to handle a string that contains an invalid number. Since [ruby/ruby@a0e438c#diff-6b866d482baf2bdfd8433893fb1f6d36R144](https://github.com/ruby/ruby/commit/a0e438cd3c28d2eaf4efa18243d5b6edafa14d88#diff-6b866d482baf2bdfd8433893fb1f6d36R144) this case raises an `ArgumentError`. `String.to_f` returns 0.0 if there is not a valid number at the start of the argument, so current behavior is conserved. See https://travis-ci.org/rails/rails/jobs/463180341#L6264 Related: #34600, #34601
* | Don't expose internal `clock_gettime_supported?` class methodRyuta Kamizono2018-11-301-1/+2
| |
* | Do nothing when the same block is included again.Mark J. Titorenko2018-11-294-3/+30
| | | | | | | | | | | | | | | | | | 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]
* | Pass the test reporter by referenceyuuji.yaginuma2018-11-281-0/+1
| | | | | | | | | | | | | | | | | | | | | | This prevents the array from being dumped as a DRbObject so we can reduce communication with the server. In DRb, if `Marshal.dump` fails, `Marshal.dump` is executed again after converting the object to `DRbObject`. This also possible to reduce the execution of `Marshal.dump` by converting to a format that can be marshalized in advance using `DRbObject`. This is the same approach to Action Pack's parallel test. Ref: 5751b7ea58d7cf259dda30fb42fff51fc6ae93d5
* | Remove unnecessary reduce in Duration#inspectDaniel Colson2018-11-241-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | When the `Duration` class was introduced in 276c9f29, the `parts` were represented as an array of arrays (for example `[[:seconds, 5], [:days, 3], [:seconds, 7]]`). At that time the `reduce` in `#inspect` made sense, since we would need to get the totals for each part (the example would become `{ seconds: 12, days: 3 }`). With the current version of `Duration` we call `to_h` on the `parts` immediately on initialize, so now the `reduce` doesn't seem to be doing anything meaningful.
* | Merge pull request #34037 from reitermarkus/atomic_write-permissionsRafael França2018-11-222-1/+15
|\ \ | | | | | | `atomic_write`: Ensure correct permission when `tmpdir` is the same as `dirname`.
| * | Ensure correct permission when `tmpdir` is the same as `dirname`.Markus Reiter2018-10-022-1/+15
| | |
* | | Fix ruby warningsyuuji.yaginuma2018-11-221-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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 ```