Commit Graph

74209 Commits

Author SHA1 Message Date
George Claghorn
2af445c311
Merge pull request #36623 from alipman88/exclude_marshal_dump_from_delegate_missing_to
Exclude marshal_dump & _dump methods from being delegated via delegate_missing_to extension, fix #36522
2019-07-22 12:19:00 -04:00
Edouard CHIN
426d2f2502 Move the deprecation call after the new class has been defined:
- If we create the deprecation before the new class is defined this
  creates an issue in case you use a `TracePoint`. The
  `Tracepoint#return_value` will try to get the new class constant
  resulting in a uninitialized constant Rails::SourceAnnotationExtractor

  The problem can be reproduced like this:

  ```ruby
  @defined = Set.new

  ANONYMOUS_CLASS_DEFINITION_TRACEPOINT = TracePoint.new(:c_return) do |tp|
    next unless @defined.add?(tp.return_value)
  end

  ANONYMOUS_CLASS_DEFINITION_TRACEPOINT.enable

  require 'rails'
  require "rails/source_annotation_extractor"
  ```
2019-07-22 15:27:17 +02:00
Ryuta Kamizono
9ad8068870
Merge pull request #36723 from masakazutakewaka/fix_create_newline_between_blocks
FIX: create a newline before group, github and source
2019-07-22 13:27:15 +09:00
masakazutakewaka
386c116fb4 create a newline between blocks when gem_group, github and add_source was called. 2019-07-21 21:04:01 -07:00
Carlos Antonio da Silva
ef4d3215b1
Merge pull request #36721 from Edouard-chin/ec-errors-each
Fix deprecation on `AM::Errors` when each is called indirectly
2019-07-21 19:34:59 -03:00
y-yagi
a390001bbe
Merge pull request #35285 from masakazutakewaka/fix_railtie_add_newline_to_gemfile_insertion
Add a newline at the end of a Gemfile when it doesn't end with a newline
2019-07-21 08:24:19 +09:00
Edouard CHIN
ab21db050d Fix deprecation on AM::Errors when each is called indirectly:
- `AM::Errors#each` is implemented for the `Enumerator` module and
  get called indirectly by a bunch of method in the ruby land
  (map, first, select ...)

  These methods have a `-1` arity as they are written in C and they
  wrongly trigger a deprecation warning.

  This commit fixes that and correctectly return a `AM::Error` object
  when `each` is called with a negative arity.
2019-07-20 21:26:43 +02:00
George Claghorn
400b210354
Preserve existing attachment assignment behavior for upgraded apps
Assigning to a collection of attachments appends rather than replacing, as in 5.2. Existing 5.2 apps that rely on this behavior will no longer break when they're upgraded to 6.0.

For apps generated on 6.0 or newer, assigning replaces the existing attachments in the collection. #attach should be used to add new attachments to the collection without removing existing ones.

I expect that we'll deprecate the old behavior in 6.1.

Closes #36374.
2019-07-20 06:33:11 -04:00
masakazutakewaka
9147b284b6 Append a newline to the Gemfile if it doesn't end with a newline 2019-07-19 22:07:48 -07:00
Carlos Antonio da Silva
876548a7e7 Fix argument in doc sample of new sms_to helper [ci skip] 2019-07-19 18:10:47 -03:00
Guillermo Iguaran
ea91f9bc1c
Merge pull request #36511 from aantix/sms_link_helper
Helper method to create an sms link
2019-07-19 15:36:58 -05:00
Kasper Timm Hansen
611339015f
Merge pull request #36713 from Shopify/fix-type-in-template
Fix a minor typo in ActionView::UnboundTemplate
2019-07-19 16:52:05 +02:00
Ryuta Kamizono
2caddbf8ae
Merge pull request #36706 from kirs/dedup-optimizer-hints
[ActiveRecord] Deduplicate optimizer hints
2019-07-19 23:01:44 +09:00
Jean Boussier
bd78d3eecf Fix a minor typo in ActionView::UnboundTemplate 2019-07-19 15:18:57 +02:00
Eileen M. Uchitelle
2e8c78e164
Merge pull request #36712 from tekin/include-more-commands-in-rails-help-output
Include common commands in rails help output
2019-07-19 08:43:36 -04:00
Tekin Suleyman
773248b3f8
Include common commands in rails help output
With their descriptions commented out these commands were not included
in the rails help command's output, which is a shame as they are useful,
particularly during the development of more complex migrations.
2019-07-19 12:42:26 +01:00
Kir Shatrov
77931f4f52 [ActiveRecord] Deduplicate optimizer hints 2019-07-19 11:52:39 +01:00
Ryuta Kamizono
d3b951f326
Merge pull request #36710 from ypresto/patch-1
[ActionController] Fix send_file example for 404

[ci skip]
2019-07-19 14:59:06 +09:00
Yuya Tanaka
438af5507c
[ActionController] Fix send_file example for 404 2019-07-19 14:39:48 +09:00
y-yagi
027085a597
Merge pull request #36703 from y-yagi/script-src-xxx_and_style-src-xxx
Add support for script-src-attr / elem and style-src-attr / elem directives
2019-07-19 07:21:07 +09:00
Ryuta Kamizono
67705c8bbf
Merge pull request #36695 from kamipo/revert_unnecessary_change
Revert "Merge pull request #36676 from wjessop/change_activestorage_metadata_duration_to_bound"
2019-07-18 12:34:47 +09:00
Aaron Lipman
722c45f641 Omit marshal_dump & _dump from delegate_missing_to
Exclude missing marshal_dump and _dump methods from being delegated to
an object's delegation target via the delegate_missing_to extension.
This avoids unintentionally adding instance variables to an object
during marshallization, should the delegation target be a method which
would otherwise add them.

In current versions of Ruby, a bug exists in the way objects are
marshalled, allowing for instance variables to be added or removed
during marshallization (see https://bugs.ruby-lang.org/issues/15968).
This results in a corrupted serialized byte stream, causing an object's
instance variables to "leak" into subsequent serialized objects during
demarshallization.

In Rails, this behavior may be triggered when marshalling an object that
uses the delegate_missing_to extension, if the delegation target is a
method which adds or removes instance variables to an object being
marshalled - when calling Marshal.dump(object), Ruby's built in behavior
will check whether the object responds to :marshal_dump or :_dump, which
in turn triggers the delegation target method in the
responds_to_missing? function defined in
activesupport/lib/active_support/core_ext/module/delegation.rb

While future versions of Ruby will resolve this bug by raising a
RuntimeError, the underlying cause of this error may not be readily
apparent when encountered by Rails developers. By excluding marshal_dump
and _dump from being delegated to an object's target, this commit
eliminates a potential cause of unexpected behavior and/or
RuntimeErrors.

Fixes #36522
2019-07-17 23:22:39 -04:00
yuuji.yaginuma
efae4c268b Add support for script-src-attr / elem and style-src-attr / elem directives
These directives can be used in Chrome 75.
Ref: https://www.chromestatus.com/feature/5141352765456384
2019-07-18 10:00:54 +09:00
Yuji Yaginuma
c5a24c8ebb
Merge pull request #36603 from y-yagi/add_skip_collision_check_option
Add `skip-collision-check` option to generator
2019-07-18 07:17:47 +09:00
Rafael França
8d967534de
Merge pull request #36691 from Edouard-chin/ec-system-test-route
Don't include routes helpers inside System test class:
2019-07-17 15:11:53 -04:00
Eileen M. Uchitelle
6a50498618 Merge pull request #36700 from cpruitt/revert-36690-make-parameterize-requires-utf-8-explicit
Revert "Make UTF-8 string requirement explicit for `ActiveSupport::Inflector.transliterate`"
2019-07-17 12:18:52 -04:00
Cliff Pruitt
0deecc781a Revert "Make UTF-8 string requirement explicit for ActiveSupport::Inflector.transliterate" 2019-07-17 12:13:09 -04:00
Eileen M. Uchitelle
e4747a4965
Merge pull request #36690 from cpruitt/make-parameterize-requires-utf-8-explicit
Make UTF-8 string requirement explicit for `ActiveSupport::Inflector.transliterate`
2019-07-17 09:55:12 -04:00
Ryuta Kamizono
2a28b7c292
Merge pull request #36696 from inopinatus/support_beginless_ranges
Support beginless ranges in hash conditions.
2019-07-17 17:35:16 +09:00
Josh Goodall
b19150448b Support beginless ranges in hash conditions.
Ruby 2.7 introduces beginless ranges (..value and ...value) and as with
endless ranges we can turn these into inequalities, enabling expressions
such as

    Order.where(created_at: ..1.year.ago)
    User.where(karma: ...0)
2019-07-17 16:11:57 +10:00
Kasper Timm Hansen
32e5f9049c
Merge pull request #36635 from abhaynikam/36332-fix-engine-documentation-to-remove-js-directory-mention
Fixed the engine documentation to not mention of assets/javascript in directory structure [ci skip]
2019-07-17 05:50:18 +02:00
Ryuta Kamizono
559ffacfd9 Revert "Merge pull request #36676 from wjessop/change_activestorage_metadata_duration_to_bound"
This reverts commit a307c697b28e3c8b2860d2274c23e4d95dc164ae, reversing
changes made to f30f76af747858826d3618866676cd5a4979e64a.

Reason: This assertion is not failed even without this PR since both
ffprobe versions (3.2.14 and 4.1.3) return the same duration 5.166648
for `video.mp4`.
So there is no need to touch this assertion at this point.
2019-07-17 09:59:03 +09:00
Rafael França
1b984fc258
Merge pull request #36694 from kirs/timeout-error-superclass
[ActiveRecord] Superclass for aborted queries
2019-07-16 23:16:23 +01:00
Kir Shatrov
730d810b0d [ActiveRecord] Superclass for aborted queries 2019-07-16 22:39:21 +01:00
Edouard CHIN
2dbb904c5e Don't include routes helpers inside System test class:
- https://github.com/rails/rails/pull/36283 made a change to
  make SystemTest inherits from ActiveSupport::TestCase instead
  of ActionDispatch::IntegrationTest.

  With this change, the route helpers are now directly included inside
  the SystemTest class. This causes an edge case in case you have a
  routes whos name starts with `test_`, minitest will consider it as a
  test and will try to run it ab39d35fb4/lib/minitest/test.rb (L66)

  This PR uses a proxy and deleted missing method to a dummy class
  that has all the route helpers.
2019-07-16 22:18:32 +02:00
Rafael Mendonça França
d473561071
Add missing period [ci skip] 2019-07-16 21:01:32 +01:00
Rafael França
64fa70a9d1
Merge pull request #36692 from kirs/mysql2-adapter-timeout
Raise specific exception on Mysql2::Error::TimeoutError
2019-07-16 20:58:41 +01:00
Kir Shatrov
080939c987 Raise specific exception on Mysql2::Error::TimeoutError 2019-07-16 20:24:27 +01:00
Rafael França
8a9a96c7e8
Merge pull request #36648 from louim/patch-1
Update message verifier documentation [ci skip]
2019-07-16 20:22:55 +01:00
Cliff Pruitt
05f9e3ef92 Make UTF-8 string requirement explicit for transliterate
It's noted in #34062 that String#parameterize will raise an `Encoding::CompatibilityError` if the string is not UTF-8 encoded. The error is raised as a result of passing the string to `.unicode_normalize`.

This PR raises a higher level `ArgumentError` if the provided string is not UTF-8 and updates documentation to note the encoding requirement.
2019-07-16 14:51:57 -04:00
Gannon McGibbon
85b422bd7f
Merge pull request #36667 from gmcgibbon/clarify_logger_set_in_log_subscriber_docs
Specify log subscribers need a logger set before they can receive events
2019-07-16 12:10:37 -04:00
Rafael França
da4e18c5c2
Merge pull request #36685 from Shopify/as-depedencies-unhook-fix
Fix Loadable.exclude_from to also reset Kernel#require
2019-07-16 15:38:11 +01:00
Rafael França
fdd5894aa9
Merge pull request #36639 from Edouard-chin/ec-am-errors-fullmessages
Move the `ActiveModel:Errors#full_message` method to the `Error` class:
2019-07-16 14:37:38 +01:00
Rafael Mendonça França
650c070150
Reuse the exception class name in all places in the wrapper 2019-07-16 14:33:47 +01:00
Rafael Mendonça França
238d36715e
Make the selent exceptions configurable on the exception wrapper 2019-07-16 14:28:59 +01:00
Rafael Mendonça França
a115a4cc79
Merge pull request #31634 from afcapel/reduce-routing-error-log-noise
Reduce log noise handling ActionController::RoutingErrors
2019-07-16 14:16:28 +01:00
Edouard CHIN
d204a09df2 Switch to use class_attribute:
- Since `ActiveModel::Error` can now be inherited by
  `ActiveModel::NestedError`, when the latter generates a
  `full_message`, the `i18n_customize_full_message` accessor set in
  the parent class is not set.

  This commit fixes that by using a `class_attribute` instead.
2019-07-16 14:28:38 +02:00
Edouard CHIN
b677adede0 Move the ActiveModel:Errors#full_message method to the Error class:
- One regression introduced by the "AM errors as object" features is
  about the `full_messages` method.

  It's currently impossible to call that method if the `base` object
  passed in the constructor of `AM::Errors` doesn't respond to the
  `errors` method.
  That's because `full_messages` now makes a weird back and forth trip

  `AM::Errors#full_messages` -> `AM::Error#full_message` -> `AM::Errors#full_message`

  Since `full_message` (singular) isn't needed by AM::Errors, I moved
  it to the `AM::Error` (singular) class. This way we don't need to
  grab the `AM::Errors` object from the base.
2019-07-16 14:28:38 +02:00
Jean Boussier
223a187b9e Fix Loadable.exclude_from to also reset Kernel#require 2019-07-16 10:56:10 +02:00
Matthew Draper
5a9301ce47
Merge pull request #36557 from sikachu/fix-source-annotation-extractor-annotation
Fix problem with accessing deprecated constant proxy's subclass
2019-07-16 13:39:00 +09:30