なるようになるブログ

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

rails commit log流し読み(2020/06/02)

2020/06/02分のコミットです。

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

actionpack/CHANGELOG.md


Merge pull request #38674 from jeremy/brotli

actionpack/lib/action_dispatch/middleware/static.rbの修正です。

ActionDispatch::StaticにBrotliファイルのサポートを追加しています。

static fileのチェックをする際に、まずはじめに圧縮されたファイル(Brotli (.br)とzip (.gz))があるかのチェックを行い、圧縮されたファイルがある場合、それらのファイルを返すようになっています。


Don't recommend disabling CSRF protection [ci skip]

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

RequestForgeryProtectionのdocで、JSON formatの場合にCSRF protectionを無効化するexampleを記載していたのを削除しています。

XHR requestsならCSRF attackから安全だから、というのが理由だったのが、それがそもそも間違い(same originが安全である理由となっていたが、same originではCSRF attackに対して安全ではない)だった為。


Merge pull request #39493 from rails/fix-current-attributes-reset-in-models

activesupport/lib/active_support/current_attributes/test_helper.rbactivesupport/lib/active_support/railtie.rbの修正です。

テストの前処理/後処理でActiveSupport::CurrentAttributesのreset処理が必ず行われるよう修正しています。


Catch Time.zone before TestHelper resets it to UTC

activesupport/test/current_attributes_test.rbの修正です。

テストでTime.zoneUTCに変更する前に、元のzoneの値を保持し、テスト終了後に元の値に戻すよう修正しています。


Merge pull request #39049 from krzysiek1507/fix/hash-with-indifferent-access-update

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

HashWithIndifferentAccess#updateメソッドで引数のhashの要素数をチェックするのにone?を使用していたのを、size == 1を使用するよう修正しています。

one?だと実際の要素数が2以上の可能性がある(例えば、[nil, {}, nil].one?がtrueになる)為。


Fix test name that no longer raises exception

railties/test/generators/generated_attribute_test.rbの修正です。

exceptionがraiseしないテストのテスト名がraises_exceptionとなっていたのを修正しています。


Merge pull request #39501 from kamipo/alias_attribute_for_validation

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

alias attributeをvalidates_uniqueness_ofに指定した場合に、正しくvalidationが動作するよう修正しています。