なるようになるブログ

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

rails commit log流し読み(2018/09/28)

2018/09/28分のコミットです。

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

railties/CHANGELOG.md

activerecord/CHANGELOG.md

activejob/CHANGELOG.md

activesupport/CHANGELOG.md


Remove Rails 5.0 workaround from ActionCable::Channel::TestCase

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

ActionCable::Channel::TestCase#subscribeメソッドにRails 5.0向けのワークアラウンドコードがあったのを削除しています。

gem(action-cable-testing)からコードを持ってきた際に、消し忘れていたとの事です。


Merge pull request #33994 from gmcgibbon/rails_g_model_migrations_paths

activerecord/lib/rails/generators/active_record/model/model_generator.rbの修正です。

model generatorにmigrationファイルを生成するpathを指定する為の--migrations_pathsオプションを追加しています。

Add migrations_paths option to migration generatorのmodel generator版。


Merge pull request #31604 from fatkodima/reverting-transaction

Active Recordの修正です。

migrationファイルでtransactionメソッドを使用していた場合に、transactionメソッド内の処理がreverting commandになっていなかったのを修正しています。

例。

class CreateTopics < ActiveRecord::Migration[6.0]
  def change
    transaction do
      create_table :topics do |t|
        t.string :title
      end
    end
  end
end

上記のようなmigirationをdb:rollbackで実行した場合、元々はtransaction内のcreate_tableがそのまま実行されていたのが、今回の修正でdrop_tableが実行されるようになっています。


Make update_all preparable

activerecord/lib/active_record/relation.rbactiverecord/lib/arel/visitors/mysql.rbの修正です。

update_allで実行するSQLでprepared statementを使用するよう修正しています。


Fix optionally scoped root route unscoped access

actionpack/lib/action_dispatch/routing/mapper.rbの修正です。

optionally scopedを複数定義 + その中でroot pathを定義した場合に、root pathが"/"ではなく空になってしまうバグがあったのを修正しています。


Merge pull request #33986 from matt17r/patch-1

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

belongs_toメソッドのdoc内のid等幅フォントで表示する為に+で囲むよう修正しています。


Merge pull request #33995 from Edouard-chin/ec-active-job-subset-arg

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

assert_enqueued_withassert_performed_withメソッドのargs引数にProcを使用出来るよう修正しています。

Procの引数にはjobに実際に渡された引数が渡されるようになっており、引数が期待通りの値になっているかどうかをチェックするのに使用する想定、との事です。


Make update_counters preparable

Active Recordの修正です。

update_countersで実行するSQLでprepared statementを使用するよう修正しています。


Remove visit_Fixnum and visit_Bignum

activerecord/lib/arel/visitors/to_sql.rbの修正です。

Visitors::ToSql classから不要なvisit_Fixnumvisit_Bignumメソッドを削除しています。


Revert "record who created the node when $DEBUG is true"

activerecord/lib/arel/nodes/node.rbの修正です。

Nodes::Node classに、$DEBUGが指定されている時だけcallerを保持しておく、というデバッグ用の処理があったのを削除しています。


Extract Arel.arel_node? helper method

Active Recordの修正です。

Arelのnodeかどうかのチェック処理をメソッド(Arel.arel_node?)に切り出しています。


Fixing an edge case when using objects as constraints

actionpack/lib/action_dispatch/routing/mapper.rbの修正です。

constraints用のclassにcallメソッドを定義している場合に、contraintの引数チェック処理でエラーになってしまうバグがあったのを修正しています。


Add probot autolabeler config

.github/autolabeler.ymlの修正です。

probot/autolabeler用の設定ファイルを追加しています。変更されたファイルから自動でlabelをつける為のbotだそうです。


Add configuration to no-response probot plugin

.github/no-response.ymlの修正です。

probot/no-response用の設定ファイルを追加しています。

こちらは、issue作成者にもっと情報を下さい、と伝えているのにレスポンスが無いissueを自動でcloseするようのbotです。


Handle more unsafe String methods (#33990)

activesupport/lib/active_support/core_ext/string/output_safety.rbの修正です。

html safeなStringに対して、delete_prefix(!)delete_suffix(!)を呼び出した際の結果がhtml safeなままになっていたのを、他のメソッド同様、unsafeになるよう修正しています。

# before
string = '<!--evil-->'.html_safe
string.delete_prefix!('<!--')
string.html_safe? # => true

# after
string = '<!--evil-->'.html_safe
string.delete_prefix!('<!--')
string.html_safe? # => false

合わせて、[]=replaceinsertでStringを追加する際に、HTML特殊文字を適切にエスケープするよう修正しています。


Merge pull request #31441 from mrhead/rails-ujs-xhr-redirects

actionview/app/assets/javascripts/rails-ujs/features/disable.coffeeの修正です。

response headerにX-Xhr-Redirectが含まれている場合に、disableになっているelementをenableにしないよう修正しています。

Turbolinksを使用している場合に、XHR redirects実行時にdisableになっていたelement(e.g.: submitボタン)がenableになってしまう、というバグがあり、その修正です。

なお、これが正常に動作するには、Turbolinks側でX-Xhr-Redirect headerを返す対応が必要で、そちらはmasterには含まれていますがまだリリースはされていません。参考: Set X-XHR-Redirect header


[ci skip] Recommend testing information displayed over object stored

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

What to include in your Functional Testsの項にある、controllerのテストで確認すべき内容に、レスポンスで正しい情報が表示されている事、を追加しています。


Merge pull request #33880 from robbertbrak/master

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

Transaction Callbacksの項にある、after_commitafter_rollback callbacksの処理中に例外が発生した場合の挙動についての説明の言い回しを修正しています。


LoggerSilence doesn't require concurrent:

activesupport/lib/active_support/logger_silence.rbactivesupport/lib/active_support/logger_thread_safe_level.rbの修正です。

activesupport/lib/active_support/logger_silence.rbから使用していないconcurrentのrequireを削除、及び、Concurrent::Mapを使用しているactivesupport/lib/active_support/logger_thread_safe_level.rbconcurrentをrequireするよう修正しています。


Bugfix ActiveRecord::Relation#merge special case of from clause

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

ActiveRecord::Relation#mergeに、mergeを呼び出したRelationとは違うbase classを使用しているRelationを指定した場合に、baseのtableが予想外に置き換わってしまう(引数に指定した方のRelationになってしまう)バグがあったのを修正しています。

例。

# before
Comment.joins(:post).merge(Post.from("posts")).to_sql
# => SELECT "comments".* FROM posts INNER JOIN "posts" ON "posts"."id" = "comments"."post_id"

# after
Comment.joins(:post).merge(Post.from("posts")).to_sql
# => SELECT "comments".* FROM comments INNER JOIN "posts" ON "posts"."id" = "comments"."post_id"

Merge pull request #33570 from mohitnatoo/queue_adapter_name_doc

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

ActiveJob::ActiveJob moduleのqueue_adapter_nameメソッドにdocを追加しています。


Merge pull request #33348 from ruralocity/update-validation-contexts-guide

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

Common Validation Optionsの項の、:onオプションについて説明している箇所のexampleコードの処理が不足していたのを追加、及び、exampleコードについての説明を修正しています。