なるようになるブログ

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

rails commit log流し読み(2015/12/07)

2015/12/07分のコミットです。

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

activerecord/CHANGELOG.md


Merge pull request #22480 from keepcosmos/add-translate-test

activemodel/test/cases/translation_test.rbの修正です。

namespace付きmodelをtranslateした場合のテストを追加しています。


[ci skip] Add a dollar sign to each command in the READMEs

各READMEの修正です。

コンソールでコマンドを実行するexampleを記載している箇所で、コンソールを表すのにシャープを使用している箇所があったのを、他の箇所同様ドルマークを使用するよう修正しています。

-  % gem install actionpack
+  $ gem install actionpack

Merge pull request #22453 from wjessop/use_action_dispatch_default_tld_length

actionpack/test/dispatch/request_test.rbの修正です。

request処理のテストでtld_lengthのデフォルトの値を1に固定していたのを、実際の値(ActionDispatch::Http::URL.tld_length)を使用するよう修正しています。


Merge pull request #22428 from thedarkone/subs-notif

activesupport/lib/active_support/notifications/fanout.rbactivesupport/lib/active_support/notifications/instrumenter.rbの修正です。

ActiveSupport::Notifications.instrumentメソッドの内でActiveSupport::Notifications.subscribeメソッドを呼び出した際に、時折エラーにバグがあったのを修正しています。

ActiveSupport::Notifications.instrument('foo') do
  ActiveSupport::Notifications.subscribe('foo') {}
end

stateの管理が正しく行えてなかったのが問題だったようです。こんな使い方するんですねえ。


Introduce after{create,update,delete}commit callbacks

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

after{create,update,delete}commit callbacksを追加しています。

名前の通りで、それぞれのタイミングのafter_commitで行う処理を定義する為のメソッドです。このメソッドを使う事で、元々after_commitメソッドonオプションでタイミングを定義していたのが不要になります。

# Before:
after_commit :add_to_index_later, on: :create
after_commit :update_in_index_later, on: :update
after_commit :remove_from_index_later, on: :destroy

# After:
after_create_commit  :add_to_index_later
after_update_commit  :update_in_index_later
after_destroy_commit :remove_from_index_later

Push before_sending to super class

Action Packの修正です。

Live::Response#before_sendingメソッドの処理を、親クラスであるResponse#before_sendingメソッドに移動しています。

Live::ResponseクラスとResponseクラスを統合する予定があり、その対応の一環のようです。

合わせて、空のrequest classを作成する為のActionDispatch::Request.emptyメソッドを追加しています。これは各テストコードで空のrequest classを作成する処理がハードコードされており、それを避ける為。


Stop violating law of demeter in response cookie_jar

actionpack/lib/action_dispatch/http/request.rbactionpack/lib/action_dispatch/http/response.rbactionpack/lib/action_dispatch/middleware/cookies.rbの修正です。

Response#before_sendingメソッドで直接cookie_jarの#commit!メソッドを呼び出していたのを、新規に#commit_cookie_jar!メソッドを追加し、そちら経由で処理を行うよう修正しています。


Only commit the cookie jar if it hasn't been committed

actionpack/lib/action_dispatch/http/response.rbの修正です。

#before_sendingメソッドcookie jarをコミットする際、コミット済みかどうかを確認し、未コミットの場合のみコミット処理を行うよう修正しています。


Make sure we touch all the parents when touch_later.

Acitive Recordの修正です。

touch_later実行時に、全ての親クラスをtouchするよう修正しています。

複数レコードに対するtouch処理が一度だけ行われるよう修正した対応(Batch touch parent records](https://github.com/rails/rails/pull/19324))の影響で、曽祖父に対するtouch処理が動かなくなる、というバグが発生してしまい、その対応として修正しています。


Typo correction

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

dependent: :destroydependent: destroyにタイポしていたのを修正しています。