なるようになるブログ

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

rails commit log流し読み(2024/10/07)

2024/10/07分のコミットです。

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

activemodel/CHANGELOG.md

activerecord/CHANGELOG.md


Add except_on option for validations

activemodel/lib/active_model/validations.rbactivemodel/lib/active_model/validations/validates.rbの修正です。

特定のcontextの場合にvalidationsをskip出来るようにする為の:except_onオプションを追加しています。:except_onオプションが指定された場合、そのcontextでのみvalidationがskipするようになっています。

class User < ApplicationRecord
  validates :birthday, presence: { except_on: :admin }
end

user = User.new
user.save(context: :admin) # `birthday`に関するvalidationが実行されない

Fix multiple test leaks and inconsistencies in railties tests

railtiesの修正です。

railtitesのテスト実行にグローバルの情報(e.g. Rails::Generators.namespaceRails.app_class)がテスト内で更新されてそのままになっていたのを、テストの後処理で元の値に戻すよう修正しています。


Update zeitwerk to silence mutex_m deprecation warnings

Gemfile.lockの修正です。

zeitwerk gemを最新バージョンに更新しています。mutex_mに関するdeprecateメッセージが表示されないようにする為。


Fix test leak due to using class instance variables and inheritance

railties/test/configuration/dynamic_options_test.rbの修正です。

テスト内でRails::Railtie::Configuration@@optionsの値を書き換えていたのを、テストの後処理で元の値に戻すよう修正しています。


Merge pull request #51507 from joshuay03/fix-polymorphic-has-many-through-with-association-scope

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

has_many through associationにscopeを指定している、かつ、associationがpolymorphicの場合に、scopeが誤ったjoinに対してapplyされてしまうバグがあったのを修正しています。


Fix "Test is missing assertions" in middleware_stack_proxy_test.rb

railties/test/configuration/middleware_stack_proxy_test.rbの修正です。

middleware_stack_proxy_test.rbのテストでTest is missing assertionsのwarningが出ていたのを、assertionのcountを明示的にincrementしてwarningが出力されないよう修正しています。


Merge pull request #53176 from Stellenticket/polymorphic_inverse_of_chain

activerecord/lib/active_record/associations/has_many_through_association.rbの修正です。

has_many through associationにscope、かつ、associationがpolymorphic、かつ、 inverse_ofが指定されている場合に、そのassocaitionに対するsaveがエラーになってしまうバグがあったのを修正しています。


Fix changelog typo from #51464

actionpack/CHANGELOG.mdの修正です。

[Fix #51463] Raise an error when invalid :only or :except options are given to #resource or #resourcesの対応のエントリーでオプション名をタイポしていたのを修正しています。


Update error_reporting.md

rails guideのError Reporting in Rails Applicationsの修正です。

Reporting and Swallowing Errorsセクション内にあるRails.error.handlefallbackオプションを指定した場合のexampleコードで、メソッド名をタイポしている箇所があったのを修正しています。