2017/09/01分のコミットです。
CHANGELOGへの追加はありませんでした。
Ignore files already deleted on GCS file deletions
activestorage/lib/active_storage/service/gcs_service.rb
の修正です。
ActiveStorage::Service::GCSService#delete
メソッドでファイルが既に削除済みだった場合(Google::Cloud::NotFoundError
が発生した場合)はエラーを無視するよう修正しています。
Fix can't modify frozen String
error in XmlMini_JDOM
activesupport/lib/active_support/xml_mini/jdom.rb
の修正です。
XmlMini_JDOM
moduleでcan't modify frozen String
エラーが発生してしまうバグがあったのを修正しています。
Have attachments touch their records
activestorage/app/models/active_storage/attachment.rb
の修正です。
attachmentsを更新したらrecord
も更新するよう、touch
オプションを設定しています。
- belongs_to :record, polymorphic: true + belongs_to :record, polymorphic: true, touch: true
Merge pull request #29233 from matthewd/redefine-method
Active Supportの修正です。
Rubyのwarningを出さずにメソッドの再定義を行う為の、silence_redefinition_of_method
メソッドを追加しています。
普通にメソッドを再定義しようとすると既にメソッドがある為Rubyのwarningが発生します。それを避ける為、今まではremove_possible_method
メソッドを先に呼び出してメソッドを未定義にするようにしていました(redefine_method
メソッド内でもそのような挙動になっています)。が、メソッドを再定義する、という事をする為にメソッドを未定義にする、というのは目的がわかりにくいのでは、という事で新たにremove_possible_method
を使用せずに再定義するメソッドが追加されました。
実装は下記の通りです(Ruby 2.3以降の場合)。
# Marks the named method as intended to be redefined, if it exists. # Suppresses the Ruby method redefinition warning. Prefer # #redefine_method where possible. def silence_redefinition_of_method(method) if method_defined?(method) || private_method_defined?(method) # This suppresses the "method redefined" warning; the self-alias # looks odd, but means we don't need to generate a unique name alias_method method, method end end
alias_method
を使用して対応しているんですねえ。
Remove needless silence_warnings
ailties/test/application/configuration_test.rb
の修正です。
environment
ファイルのrequire処理をsilence_warnings
で囲むようにしていたのを、silence_warnings
を削除しています。
元々はSassで大量に発生するRubyのwarning出力を抑止する為だったのですが、現状リリースされているSassではもうwarningは出ないようになっている為。
double assign is no longer an effective workaround for unused variable warning
actionview/lib/action_view/template.rb
の修正です。
ActionView::Template#locals_code
メソッドでkeyの設定処理にダブルアサインを使用していたのを、使用しないよう修正しています。
- locals.each_with_object("".dup) { |key, code| code << "#{key} = #{key} = local_assigns[:#{key}];" } + locals.each_with_object("".dup) { |key, code| code << "#{key} = local_assigns[:#{key}]; #{key} = #{key};" }
Rubyのwanring(assigned but unused variable)を避ける為にダブルアサインを使用していたらしいのですが、Ruby 2.5では上記テクニックが使えなくなった(普通にwarningが出るようになった)為、修正したとの事です。
参考:ruby-trunk-changes r59584 - r59586 - PB memo
Suppress “unused variable” in Ruby 2.5
activesupport/test/test_case_test.rb
の修正です。
local_scope
変数の設定処理にダブルアサインを使用していたのを、使用しないよう修正しています。理由は先のコミット同様。
Hash#transform_keys is in Ruby 2.5+
activesupport/lib/active_support/core_ext/hash/keys.rb
の修正です。
Hash
にtransform_keys
メソッドが定義されていない場合のみメソッドを定義するように修正しています。Ruby 2.5ではRuby本体にHash#transform_keys
メソッドが定義されている為。
actionpack/test/dispatch/response_test.rb
の修正です。
使用していない変数の変数名の先頭に_
を追加しています。
- status, headers, body = app.call(env) + _status, headers, _body = app.call(env)
戻り値が複数あって一部値は使用している為上記のような対応を行っています。
:warning: assigned but unused variable - message
activerecord/test/cases/associations/join_model_test.rb
の修正です。
使用していない変数を削除しています。
actionpack/lib/action_controller/metal/rendering.rb
の修正です。
使用していないactive_support/core_ext/string/filters
のrequireを削除しています。
CI with the latest stable(GA) version of MariaDB 10.2
.travis.yml
の修正です。
CIで使用するMariaDBのバージョンを10.2に更新しています。
Skip test_remove_column_with_multi_column_index
activerecord/test/cases/migration/columns_test.rb
の修正です。
test_remove_column_with_multi_column_index
をMariaDB、かつ、MariaDBのバージョンが10.2.8
以上の場合実行しないよう修正しています。
MariaDB 10.28から、複数列のUNIQUE制約の一部である列を削除することはできなくなった為、との事です。
参考:DROP COLUMN [IF EXISTS] col_name [CASCADE|RESTRICT]
add_reference
should respect column position for both reference id and type columns
activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
の修正です。
add_reference
メソッドでpolymorphic
オプションにtrueを指定した場合に、カラムポジションの指定が正しく動作しないバグがあったのを修正しています。