なるようになるブログ

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

rails commit log流し読み(2022/04/06)

2022/04/06分のコミットです。

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

actionpack/CHANGELOG.md


Merge pull request #44833 from ghousemohamed/extend-test-cases-in-ar-for-methods-accepting-blocks

activerecord/test/cases/relations_test.rbの修正です。

createfind_or_create_byなどにblockを指定した場合のテストを追加しています。


Merge pull request #44783 from p8/guides/move-validates-associated

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

validates_associatedメソッドの説明を、他のvaliates系メソッドの説明の近くに移動しています。


Merge pull request #44574 from NobodysNightmare/fix-activestorage-cdn-example

rails guideのActive Storage Overviewの修正です。

CDNから画像を参照する場合のexampleコードに明示的なexpires_inの指定を追加しています。Rails側の処理が変わった場合にもexpires_inの指定が行われるようにする為。


Merge pull request #44592 from ghiculescu/remote-ip-docs

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

Remote IPのdocについて、言い回しの修正、リンク切れページの修正等を行っています。


Add docs about how to use remote browser in test (#44311)

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

SeleniumHQ/docker-seleniumのような、remote browserをsystem testで使う方法についての説明を追加しています。


Remove autoload to unused constant

activejob/lib/active_job.rbの修正です。

存在しない定数に対するautoloadの指定があったのを削除しています。


All intermediate delegation methods should preserve kwargs flag

Ruby 3.2で*rest parameterを指定しているメソッドでkwargs flagを維持しなくなった為、kwargs flagをdelegateしたいメソッドに対して明示的にruby2_keywordsを指定するよう修正しています。

参考: Bug #18625: ruby2_keywords does not unmark the hash if the receiving method has a *rest parameter


Merge pull request #44283 from simbasdad/csrf_token_storage

Action Packの修正です。

CSRF Tokenを保持・取得する処理を独自にカスタマイズ出来るよう修正しています。カスタマイズしたい場合、fetchstoreresetを実装したクラスを作成し、そのクラスをprotect_from_forgerystoreオプションにに指定すれば良いようになっています。

class CustomStore
  def fetch(request)
    # Return the token from a custom location
  end

  def store(request, csrf_token)
    # Store the token in a custom location
  end

  def reset(request)
    # Delete the stored session token
  end
end

class ApplicationController < ActionController::Base
  protect_from_forgery store: CustomStore.new
end

Remove deprecated comparing AC::Parameters with a hash assertion

actionpack/test/controller/parameters/parameters_permit_test.rbの修正です。

deprecatedになったActionController::ParametersHashの比較処理があったのを削除しています。


Handle renaming of global_constant_state in Ruby 3.2

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

Ruby 3.2で削除されたRubyVM.stat(:global_constant_state)を使用している箇所があったのを修正しています。