なるようになるブログ

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

rails commit log流し読み(2016/10/22)

2016/10/22分のコミットです。

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

activerecord/CHANGELOG.md

activesupport/CHANGELOG.md


Additional fix for argument-splat ordering differences.

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

ActiveSupport::Callbacks#run_callbacksメソッドでexpand_call_templateメソッドの戻り値をArrayとして扱っていたのを、個別に変数に格納するよう修正しています。

-              expanded = current.expand_call_template(env, invoke_sequence)
-              expanded.shift.send(*expanded, &expanded.shift)
+              target, block, method, *arguments = current.expand_call_template(env, invoke_sequence)
+              target.send(method, *arguments, &block)

Explicitly unpack the expanded args to avoid execution order diff.の対応と同様、先に行われる事を期待していたスプラッティングがshiftより後に行われてしまっている為。


Add examples of queue_adapter and perform_enqueued jobs to API Docs.

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

ActiveJob::TestHelper#perform_enqueued_jobs#queue_adapterメソッドにドキュメントを追加しています。


Fixed: Optimistic locking does not work well with null in the database

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

optimize lockに使用するカラムがnullだった場合に、ロック処理が正しく動作しないバグがあったのを修正しています。


Added ability update locking_column value

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

optimize lockに使用するカラムの値(lock version)を明示的に更新出来るよう修正しています。またその際、lock versionが自動で更新されないよう(指定した値がそのまま反映されるよう)にしています。


Revert "Undefine assings in IntegrationTest"

IntegrationTestクラスでassignsをundefするよう修正した、Undefine assings in IntegrationTestをrevertしています。

元々、IntegrationTestクラスでassignsを定義している為に、rails-controller-testing gemで定義しているassignsIntegrationTest動作しなと思われるという事でundefしたようなのですが、どうも関係無いようだったのでrevertしたようです。

参考:"assigns" in integration test not working · Issue #28 · rails/rails-controller-testing


Skip test that depends on RubyVM when it is not available (JRuby).

activesupport/test/executor_test.rbの修正です。

class_serialが増えない事を確認するテストを、RubyVMが無い環境(JRuby)では行わないようskip処理を追加しています。


Prevent the test framework from being loaded in production mode

railties/lib/rails/commands/test/test_command.rbrailties/lib/rails/test_unit/railtie.rbの修正です。

initializerで行っていたRails::LineFilteringActiveSupport::TestCaseにextendする処理を、実際にtest runner実行時に行うよう修正しています。

initializerで行ってしまうと、環境を問わずActiveSupport::TestCaseのload処理が行われてしまう為、productionのようなActiveSupport::TestCaseのload処理が不要な環境でのload処理を行われないようにする為にextendのタイミングを修正したとの事です。

が、これは後ほどon_loadを使用するよう修正されています。


Soften this test since YAML.dump may produce keys in other orders.


Use on_load to trigger commandline processing code

activesupport/lib/active_support/test_case.rbrailties/lib/rails/commands/test/test_command.rbrailties/lib/rails/test_unit/railtie.rbの修正です。

Rails::LineFilteringActiveSupport::TestCaseにextendする処理を、ActiveSupport.run_load_hooksを使用してActiveSupport::TesCaseがloadされた際に行うよう修正しています。


Merge pull request #26860 from headius/soft_ordering_in_yaml_dump

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

ActionController::Parametersyamlにserializeするテストで、serialize結果をまとめて1つのassertionで書くんするようになっていたのを、行毎にassertionをわけるよう修正しています。

-    assert_equal <<-end_of_yaml.strip_heredoc, YAML.dump(params)
-      --- !ruby/object:ActionController::Parameters
-      parameters: !ruby/hash:ActiveSupport::HashWithIndifferentAccess
-        key: :value
-      permitted: false
-    end_of_yaml
+    yaml_dump = YAML.dump(params)
+    assert_match("--- !ruby/object:ActionController::Parameters", yaml_dump)
+    assert_match(/parameters: !ruby\/hash:ActiveSupport::HashWithIndifferentAccess\n\s+key: :value/, yaml_dump)
+    assert_match("permitted: false", yaml_dump)

JRubyYAML engineはlibyamlではなく、serializeした結果の順番はCRubyとは異なる為、との事です。へー。


Lazy-load blade for actioncable tests; no blade on JRuby.

actioncable/Rakefileの修正です。

ファイルの先頭で行っていたbladeのrequireを、実際に使用する箇所でrequireするよう修正しています。

JRubyではblade gemは提供されておらず、ファイルの先頭でrequireしてしまうとJRubyでテスト実行時にそこでエラーになってしまう為。


Merge pull request #26826 from claudiob/add-require

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

不足していたactive_support/core_ext/hash/indifferent_accessのrequireを追加しています。


Merge pull request #26843 from denisovlev/strptime_timestamps

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

ActiveSupport::TimeZone#strptimeで seconds (%s) 及び milliseconds (%Q) formatもサポートするよう対応しています。

# before
ActiveSupport::TimeZone.new('UTC').strptime("1470272280000", "%Q")
# => Sat, 22 Oct 2016 00:00:00 UTC +00:00

# after
ActiveSupport::TimeZone.new('UTC').strptime("1470272280000", "%Q")
#=> Thu, 04 Aug 2016 00:58:00 UTC +00:00

Fix regression caused due to removal of select method from CollectionAssociation

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

ActiveRecord::QueryMethods#selectにblockを渡す処理のサポートがdeprecateになりました。

正確には、Remove unnecessary `select` method for `CollectionProxy`で処理が削除されていたのですが、まずdeprecateにすべきだろう、という事でblockを渡された場合deprecate messageを出すようにしています。


Merge pull request #26810 from maclover7/jm-fix-26802

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

ActionView::Helpers::UrlHelper#to_form_paramsのattribute引数にActionController::Parametersインスタンスが渡された場合、Hashに変換して処理を行うよう修正しています。

button_toメソッドにActionController::Parametersを渡した場合に正しくHTMLを生成出来るようにする為、との事です。


Merge pull request #26790 from iainbeeston/type-tests-in-their-own-files

Active Modelのテストの修正です。

ActiveModel::Typeのテストをまとめてactivemodel/test/cases/types_test.rbで行っていたのを、各type class毎にテストファイルを分けるよう修正しています。