なるようになるブログ

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

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

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

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

actiontext/CHANGELOG.md

activerecord/CHANGELOG.md

railties/CHANGELOG.md

activesupport/CHANGELOG.md

actionview/CHANGELOG.md


Merge pull request #50543 from santib/run-ci-on-every-pr

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

rails newで生成されるCIの設定で、mainブランチに対するPRでのみテストが実行されるようになっていたのを、全てのブランチの場合でテストが実行されるよう修正しています。


Eager load the Rails default controllers used in production (#50558)

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

productionで使われるRails内部のcontrollerをeager loadの対象にするよう修正しています。


Merge pull request #50541 from bparanj/document-edge-cases-for-find

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

findメソッドのdocにfindに空のArrayやnilを指定した場合の挙動の説明を追加しています。


Enable Minitest/NonExecutableTestMethod cop

.rubocop.ymlの修正です。

Minitest/NonExecutableTestMethod copを有効にするよう修正しています。


Merge pull request #50545 from santib/use-all-ci-cores

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

rails newで生成されるCIの設定で、Parallelize testsが使用されるよう明示的にPARALLEL_WORKERS envの設定を追加しています。


Merge pull request #50547 from faqndo97/run_importmap_audit_on_ci

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

rails newで生成されるCIの設定で、Javascript Dependenciesのsecurity vulnerabilitiesのscan(bin/importmap audit)の設定を追加しています。


Merge pull request #49857 from mguan2020/ujsfix

rails guideのUpgrading Ruby on Railsの修正です。

Upgrading from Rails 7.0 to Rails 7.1に、@rails/ujsのimport syntaxの変更についての説明を追加しています。


Merge pull request #50473 from seanpdoyle/action-text-content-pattern-matching

actiontext/lib/action_text/content.rbactiontext/lib/action_text/fragment.rbの修正です。

ActionText::Content#deconstructNokogiri::XML::DocumentFragment#elementsdelegateするよう修正しています。ActionText::Contentの内容に対してpattern matchを使用出来るようにする為。

content = ActionText::Content.new <<~HTML
  <h1>Hello, world</h1>
  <div>The body</div>
HTML

content => [h1, div]

assert_pattern { h1 => { content: "Hello, world" } }
assert_pattern { div => { content: "The body" } }

Add link to API documentation for ActionView helper method

rails guideのAction View Helpersの修正です。

Action Viewのhelper methodについて説明している箇所に、API docへのリンクを追加しています。


Add markdown codehighlight for bash script

README.mdの修正です。

languageの指定がないcode blockにlanguageの指定を行うよう修正しています。


Remove all code to work with Ruby < 3.1

Ruby 3.1未満向けのコードをまとめて削除しています。


Point rubocop to ruby 3.1

.rubocop.ymlの修正です。

TargetRubyVersionを3.1に変更、Lint/MissingCopEnableDirective等のDirectiveに関するcopを追加、及び各ファイルをcopの変更に合わせて更新しています。


Fix self is undefined for actioncable within ssr build systems by replacing it globalThis

actioncable/app/javascript/action_cable/adapters.jsの修正です。

globalThisを使用している箇所があったのを、使用しないよう修正しています。SSRの為のbuildを行う時にエラーにならないようにする為。


Merge pull request #46238 from austenmadden/resolve-validates-associated-ignores-contexts

Active Recordの修正です。

validates_associatedメソッドがonオプションに指定されたcontextを無視してしまうバグがあったのを修正しています。


Raise ArgumentError when reading from config.x with arguments

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

config.x.somethingのread処理に誤った引数が指定された場合にArgumentErrorをraiseするよう修正しています。

config.x.this_works.this_raises true # raises ArgumentError

値の設定をしようとして誤った使い方をしている場合にそれに気付けるようにする為。


Remove apply_rubocop_autocorrect_after_generate! from development.rb in build_app

railties/test/isolation/abstract_unit.rbの修正です。

テスト用のアプリケーションからconfig.generators.apply_rubocop_autocorrect_after_generate!を除外するよう修正しています。

RubocopがサポートしていないRubyでテストを実行する際にRubocopの実行でエラーになるのを避ける為。


Don't run rubocop after generation on Ruby 3.4+

railties/test/application/generators_test.rbの修正です。

apply_rubocop_autocorrect_after_generate!のテストをRuby 3.4で実行しないよう修正しています。RubocopがサポートしていないRubyでテストを実行してにRubocopの実行でエラーになるのを避ける為。


Add BACKTRACE env variable to turn off backtrace for normal running, not just tests

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

test以外のコマンドでも、BACKTRACE ENVでbacktrace cleaningの無効化を出来るよう修正しています。フレームワークのコードのデバッグをしやすくするため。

BACKTRACE=1 ./bin/rails server

Use logical core count for test parallelization

activesupport/lib/active_support/test_case.rbrailties/lib/rails/generators/rails/app/templates/github/ci.yml.ttの修正です。

parallelizing testsのデフォルトworker数を設定するのにphysical core数(Concurrent.physical_processor_count)を使用していたのを、logical core数(Concurrent.processor_count)を使用するよう修正しています。logical core数に依存した方が使用されるworker数が増え、テストが高速に実行される可能性があるため。


Merge pull request #50439 from fatkodima/migrations_paths-for-replicas

rails guideのMultiple Databases with Active Recordの修正です。

Horizontal Shardingのセクションにあるdatabase.ymlのexample内のshardingの設定から不要なmigrations_pathsの指定を削除しています。


Merge pull request #50438 from fatkodima/schema_dump-docs

rails guideのMultiple Databases with Active Recordの修正です。

Setting up Your Applicationセクションにschema_dumpの設定に関する説明を追加しています。


Handle all false args in config.x error check

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

config.xに引数が指定された場合のチェック処理で、引数がnil/falseだった場合に正しくチェック出来てなかったのを修正しています。


Fix JavaScript code fence and syntax [ci-skip]

rails guideのUpgrading Ruby on Railsの修正です。

code blocksのlang指定がなかった箇所があったのを修正しています。


Fix class name for backtrace_cleaner_test.rb

railties/test/application/backtrace_cleaner_test.rbの修正です。

backtrace_cleanerのテストのテスト名が誤っていたのを修正しています。


#render_template_to_object and #render_partial_to_object are private

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

内部でだけ使うrender_template_to_objectrender_partial_to_objectメソッドの可視性をprivateに変更しています。


Get rid of EnvHelpers at Minitest::RailsPluginTest

railties/test/minitest/rails_plugin_test.rbの修正です。

使用していないEnvHelpersのincludeを削除しています。


Make sure isolation tests are properlly parallelized

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

RailsのParallelize testsが使用されている場合に、minitest本体のparallelize処理を呼び出さないよう修正しています。


Use a different module

activesupport/test/json/encoding_test_cases.rbの修正です。

json encodingのテストで、moduleのチェックにActiveSupport::MessageEncryptorを使用していたのをActiveSupport::Testingを使用するよう修正しています。jsonに依存しないmoduleでテストをするようにするため。


Merge pull request #49943 from cjilbert504/handle-nil-form-model-object

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

form_withメソッドのmodel:引数にnilが指定された場合にArgumentErrorをraiseするよう修正しています。


Allow to force skip tests

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

テストを強制的にskipするためのforce_skipメソッドを使用出来るよう修正しています。特定のライブラリがロードされていない場合に実行したいテストで、何らかの理由で既にそのライブラリがロードされてしまっている場合にテストをskip出来るようにするため、とのことです。


Fix force_skip patch

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

先のforce_skipを定義する箇所に誤りがあったのを修正しています。


Force skip in test/core_ext/object/json_cherry_pick_test.rb

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

require_or_skipメソッド内でforce_skip`メソッドを使用するよう修正しています。


Ensure that LogSubscriber.flush_all! is called after LogSubscribers run

railties/lib/rails/rack/logger.rbの修正です。

Rack用のlogger処理で、request終了後(bodyがclose後)にLogSubscribersのflush処理(ActiveSupport::LogSubscriber.flush_all!)が実行されるよう修正しています。元々はheadersが書き込まれ後に実行されていたのですが、それだとログが正しく書き込まれない可能性があるため修正しています。


Prevent vendorizing gems fixtures in dot directories (like .bundle) from loading when running tests (#50548)

railties/lib/rails/engine.rbの修正です。

.ではじまるディレクトリからfixtureをloadしないよう修正しています。.bundleディレクトリがありその配下にgemが含まれている場合に、gem内部のfixtureがロードされてしまうのを避けるため。


Ensure installed migrations comply with rubocop-rails-omakase

actiontext/db/migrate/20180528164100_create_action_text_tables.rbactivestorage/db/migrate/20170806125915_create_active_storage_tables.rbの修正です。

Railsが生成するアプリケーション用のmigrationファイルがrubocop-rails-omakaseのチェックでエラーにならないよう修正しています。


Ensure RuboCop and Brakeman are always avaiable in CI

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

rubocop-rails-omakasebrakemantest groupに含まれてなかったのを、含むよう修正しています。CI環境でBUNDLE_WITHOUTを指定している場合にもgemがインストールされるようにする為。