なるようになるブログ

読書感想文かrailsについてかrubyについてか

rails commit log流し読み(2020/01/11)

2020/01/11分のコミットです。

CHANGELOGにのったコミットは以下の通りです。

activerecord/CHANGELOG.md


Merge pull request #38193 from Edouard-chin/ec-fix-numericality-on-abstract-class

activerecord/lib/active_record/validations/numericality.rbの修正です。

abstract classにnumericality validatorを定義した際に、その子クラスでvalidatorを使用した際にActiveRecord::TableNotSpecifiedが発生してしまっていたのを修正しています。


Merge pull request #38204 from eileencodes/fix-reading-conn-so-text-fixtures-raise-when-writing-on-replica

Active Recordの修正です。

:reading(という名前のroleの) connectionに対して書き込み処理を行った場合、必ずActiveRecord::ReadOnlyErrorがおきるよう修正しています。

test fixturesでreplicaでもwriterのconnectionを使用している為、replicaに対して書き込み処理を行った場合にActiveRecord::ReadonlyErrorが発生する事、を確認するテストが出来ない、という問題があり、その対応の為。


Merge pull request #38197 from apauly/feature/as_json-reduce-allocations

activesupport/lib/active_support/core_ext/object/json.rbの修正です。

Hash#as_jsonメソッドでオブジェクト生成数を減らすようリファクタリングしています。


Fix NumericalityValidator when precision is too high:

activerecord/lib/active_record/validations/numericality.rbの修正です。

numericality validatorで使用するprecisionのデフォルト値にFloat::DIGを使用していたのをBigDecimal.double_figを使用するよう修正しています。

Float::DIGだとクラスが保持できる有効数字を取得出来ない為。


Fix ActionController::TestSession#id to return Rack::Session::SessionId instance (#38063)

actionpack/lib/action_controller/test_case.rbの修正です。

ActionController::TestSession#idの戻り値をRack::Session::SessionIdに変更しています。

rack v2.0.8からsessionの戻り値がRack::Session::SessionIdになっており、その挙動と合わせる為。


Do not re-parse PATH_INFO when validating authenticity token

actionpack/lib/action_controller/metal/request_forgery_protection.rbの修正です。

authenticity tokenのチェック時にPATH_INFOのパース処理を行わないよう修正しています。

PATH_INFOにはquery parametersが含まれていない(はず)で、パース処理は不要な為。


[ci skip] Brazilian portuguese translation effort (#38200)

rails guideのContributing to Ruby on Railsの修正です。

Translating Rails Guidesの項に、ブラジルポルトガル語版(https://github.com/campuscode/rails-guides-pt-BR )を追加しています。


Merge pull request #38203 from jonathanhefner/plugin-put-dev-deps-in-gemfile

railties/lib/rails/generators/rails/plugin/templates/%name%.gemspec.ttrailties/lib/rails/generators/rails/plugin/templates/Gemfile.ttの修正です。

rails pluginでdev用のdependenciesをgemspecのadd_development_dependencyで定義していたのを、Gemfileで定義するよう修正しています。

bundlerで新しいgemを生成する際にGemfileを使用するようになっており、その参考と合わせる為。

参考: Remove add_development_dependency from new gems


rack 2.1.0 changed expires date format from rfc2822 to httpdate

Gemfile、及びAction Packのテストの修正です。

rack 2.1.0でexpires dateのformatが変更になり(RFC 7231に準拠するようになりました)、その影響でAction Packのテストが失敗するようなっていたのを修正しています。

また、それ以外にもActive Storageのテストが失敗するようになっていたのですが、こちらはrack側で対応された為、一時的にrackのmasterを参照するようにしています。

参考: Use .httpdate for expires date formatting


Reduce number of created objects in Hash#to_json

activesupport/lib/active_support/json/encoding.rbの修正です。

Hash#as_jsonメソッドでオブジェクト生成数を減らすようリファクタリングしています。