なるようになるブログ

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

rails commit log流し読み(2024/01/05)

2024/01/05分のコミットです。

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

railties/CHANGELOG.md

actionview/CHANGELOG.md

actioncable/CHANGELOG.md

activerecord/CHANGELOG.md


Put back the require

activesupport/test/core_ext/object/json_gem_encoding_test.rbの修正です。

テスト用のrequire_or_skipメソッドでrequire処理を誤って削除してしまっていたのを修正しています。


Remove MethodCallAssertions Ruby 2.7 work-around

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

MethodCallAssertions内にあるRuby 2.7向けのwork-around処理を削除しています。


Merge pull request #50412 from fatkodima/fix-find_by-for-cpks

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

find_byにcomposite primary keysを使用しているassociationのinstanceを指定した場合に結果が正しく取得出来ないバグがあったのを修正しています。


Merge pull request #50337 from Edouard-chin/ec-log-level

railties/lib/rails/application/bootstrap.rbrailties/lib/rails/application/configuration.rbの修正です。

Broadcast Loggerを使用した場合に、config.log_levelの設定が無視されてしまうバグがあったのを修正しています。


Add CI service files to dockerignore template

railties/lib/rails/generators/rails/app/templates/dockerignore.ttの修正です。

CI関連のファイルをdockerignoreに指定するよう修正しています。


default annotate_rendered_view_with_filenames to true in development

railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.ttの修正です。

rails newで新規にアプリを作成した場合に、デフォルトでconfig.action_view.annotate_rendered_view_with_filenamesにtrueを指定するよう修正しています。


Rename ActionView::TestCase::Behavior::{Content,RenderedViewContent}

actionview/lib/action_view/test_case.rbの修正です。

ActionView::TestCase::Behavior::ContentActionView::TestCase::Behavior::RenderedViewContentにリネームしています。

アプリ側でContentというクラスが定義されていた場合に、クラス名のコンフリクトによりActionView::TestCase::Behavior側の処理が正しく行えない、という問題があり、コンフリしなさそうな名前に変更しています。


Add assertions for stopped ActionCable streams

actioncable/lib/action_cable/channel/test_case.rbの修正です。

特定のstreamが開始していないことを確認するためのassert_not_has_stream、及び、modelに対する特定のsteamが開始していないことを確認するためのassert_not_has_stream_for assertionsを追加しています。


Parse ActionView::TestCase#rendered as DocumentFragment actionview/lib/action_view/test_case.rbの修正です。

ActionView::TestCase#renderedでHTML contentをNokogiri::XML::Documentとしてパースしていたのを、Nokogiri::XML::DocumentFragmentとしてパースするよう修正しています。partialをrenderする際など、完全なHTMLでなく特定のDOM部分だけをパースすることは通常発生するケースで、そのような場合に不要なルートのhtmlタグなどを生成しないようにするため。


Merge pull request #50464 from vlado/round_mode_missing_mode

actionview/lib/action_view/helpers/number_helper.rbのdocの修正です。

number_to_phone等のnumber_xxx系のhelperメソッドのdocに:round_modeオプションについての説明を追加しています。


Merge pull request #50482 from p8/activerecord/explain-proxy

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

lastpluckcount等のメソッドに対してexplainを指定出来るよう修正しています。

User.all.explain.count
# => EXPLAIN SELECT COUNT(*) FROM `users`

User.all.explain.maximum(:id)
# => EXPLAIN SELECT MAX(`users`.`id`) FROM `users`

Don't assume the page language is English

railties/lib/rails/templates/layouts/application.html.erbの修正です。

Railsが内部で使用するlayoutファイルでlangenが指定されていたのを削除しています。ユーザのlangがenでない可能性があり、誤っている可能性があるlangは定義しない方が良いため。


docs: update reference to main branch

rails guideのRails Internationalization (I18n) APIの修正です。

https://github.com/rack/rack-contribのデフォルトのブランチ名を最新の内容に更新しています。


Use rubocop github formatter on CI to display annotations in the UI

railties/lib/rails/generators/rails/app/templates/github/ci.yml.ttの修正です。

CIでRubocopを実行する際にgithub formatterを使用するよう修正しています。GitHubのUIでannotationとして結果が表示されるようにする為。


Remove ActionView::Renderer#render_template

actionview/lib/action_view/renderer/renderer.rbの修正です。

使用していないActionView::Renderer#render_templateメソッドを削除しています。


Rename #assert_not_has_stream #assert_has_no_stream

actioncable/lib/action_cable/channel/test_case.rbの修正です。

assert_not_has_streamをassert_has_no_streamに、assert_not_has_stream_forassert_has_no_stream_for`にそれぞれリネームしています。


Remove workaround for Ruby 2.7 at ActiveSupport::Cache#lookup_store

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

ActiveSupport::Cache#lookup_storeメソッドからRuby 2.7向けの処理を削除しています。


Add the nonce: true option for stylesheet_link_tag helper

actionview/lib/action_view/helpers/asset_tag_helper.rbの修正です。

stylesheet_link_tagにContent Security Policyのnonceを付与する為のnonce: trueオプションを指定出来るよう修正しています。javascript_include_tag nonce: trueと同じ振る舞い。


Add Naming and Pronouns headings to API wording guide [ci-skip]

rails guideのAPI Documentation Guidelinesの修正です。

Wordingセクション内の説明に見出しを追加しています。


Add "GOOD" and "BAD" examples to API wording guide [ci-skip]

rails guideのAPI Documentation Guidelinesの修正です。

Wordingセクション内の説明に、コメントやメソッドのexampleの、良い例と悪い例の説明を追加しています。


Cleanup usage of ruby2_keywords

Ruby 2.7をサポートしない事により不要になった、ruby2_keywordsの呼び出し処理を削除しています。


Name all supported methods in explain CHANGELOG entry

activerecord/CHANGELOG.mdの修正です。

lastpluckcount等のメソッドに対してexplainを指定出来るよう修正した、Name all supported methods in explain CHANGELOG entryのエントリーに、explainを指定出来るようになったメソッドを全て記載するよう修正しています。


Cleanup defined? usage

Ruby 2.7をサポートしない事により不要になった、defined?を使用してのインスタンス変数が定義済みかどうかのチェックを削除しています。


Merge pull request #50301 from p8/guides/ror-security-links

rails guideのSecuring Rails Applicationsの修正です。

もうメンテされていないgemや、古いRails向けの説明など、内容が古くなっている箇所を削除しています。


Merge pull request #50342 from JohnAnon9771/doc/improve-controlling-association-scope

rails guideのActive Record Associationsの修正です。

Controlling Association Scopeセクションに、ディレクトリ構造とscopeの関連がわかるexampleを追加しています。