なるようになるブログ

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

rails commit log流し読み(2016/07/02)

2016/07/02分のコミットです。

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

railties/CHANGELOG.md


Merge pull request #25307 from kamipo/extract_foreign_key_action_from_information_schema

Active Recordの修正です。

schema dumpを作成する際に、information_schemaからforeign key actionの情報も引き抜くよう修正しています。

foreign key actionの情報がmigrateファイルに記載されないバグがあった為対応されています。


Add regression test for foreign key schema dump caching

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

foreign keyにon_delete: :cascadeを指定した場合に、schemaファイルにon_deleteの情報が正しくdumpされる事を確認するテストを追加しています。


Fix request encoding in tests when string literals are frozen

actionpack/lib/action_dispatch/testing/integration.rbの修正です。

frozen string literalを設定している環境で、ActionDispatch::Integrationのhttp method + asオプション(ex: get '/posts', as: :json)を指定した場合に、RuntimeError(can't modify frozen String)が発生してしまうバグがあったのを修正しています。

          def append_format_to(path)
-            path << @path_format unless @url_encoded_form
+            path += @path_format unless @url_encoded_form
             path
           end

Merge pull request #25600 from pan/constantize-docfix

activesupport/lib/active_support/inflector/methods.rbのdocの修正です。

ActiveSupport::Infector.constantizeメソッドのdoc内のAPIの使い方に誤りがあったのを修正しています。


Make mutation stand out some more.

actionpack/lib/action_dispatch/testing/integration.rbの修正です。

append_format_toメソッドでの文字列追加処理のリファクタリングを行っています。

          def append_format_to(path)
-            path += @path_format unless @url_encoded_form
-            path
+            if @url_encoded_form
+              path + @path_format
+            else
+              path
+            end
           end

ただこれ誤りがあり、後ほどまた修正が行われています。


Silence DebugExceptions template render logs during exceptions

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

DebugExceptionsのtemplateをrenderする際に、そのrenderのログは出力しないよう修正しています。


Ensure logging on exceptions only includes what we expect

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

先のログ出力を制限する対応のテストを追加しています。


close hijacked i/o socket after use (fixes #25613)

actioncable/lib/action_cable/connection/stream.rbの修正です。

ActionCable::Connection::Stream#clean_rack_hijackでrack hijackのIOを初期化する前に、closeメソッドを呼び出してIOをcloseするよう修正しています


Merge pull request #24146 from matthewd/latch-as-proxy

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

ActiveSupport::Concurrency::LatchConcurrent::CountDownLatchを継承していたのを止めています。

また、合わせて、ActiveSupport::Concurrency::Latchクラスをdeprecateにしています。今後はcountの数に合わせてConcurrent::Event又はConcurrent::CountDownLatchを使う必要があります。


Merge pull request #25344 from matthewd/debug-locks

Action Pack / Active Supportの修正です。

autoload interlockでdeadlocksが発生していないかどうかを診断する為の、デバッグ情報を表示する為のみmiddleware(ActionDispatch::DebugLocks)を追加しています。デフォルトでは追加されないので、使用したい場合は自分でmiddlewareを追加する必要があります。

# config/application.rb
config.middleware.insert_before Rack::Sendfile, ActionDispatch::DebugLocks

/rails/locksにアクセスするとスレッドの情報が表示されるようになります(アクティブなスレッドがある場合のみ)。


Fix conditional order broken in ea40ec56.

actionpack/lib/action_dispatch/testing/integration.rbの修正です。

先ほど行われたappend_format_toメソッドでの文字列追加処理のリファクタリングで分岐処理に誤りがあったのを修正しています。


Merge pull request #25620 from kamipo/create_without_primary_key

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

ActiveRecord::Relation#insertメソッドで、tableにprimary keyが無い場合、connection.insertのprimary keyに明示的にfalseを渡すよう修正しています。不要なqueryが発行されるのを防ぐ為のようです。


Merge pull request #25625 from voxik/fix-rails-test-git-layout

activesupport/test/testing/file_fixtures_test.rbの修正です。

#file_fixtureのテストで、テストで使用するファイルのパスを、githubのlayoutを前提としていたのを、*を使用しどんなパスでも問題無いよう修正しています。

-    assert_match %r{activesupport/test/file_fixtures/sample.txt$}, path.to_s
+    assert_match %r{.*/test/file_fixtures/sample.txt$}, path.to_s

Do not run bundle install when generating a new plugin.

railties/lib/rails/generators/app_base.rbrailties/lib/rails/generators/rails/plugin/plugin_generator.rbの修正です。

pluginを生成時に、bundle installを実行しないよう修正しています。

bundler 1.12.0から、gemspecが正常な内容がどうか確認して、内容に問題がある場合bundle installが失敗するようになりました。

で、plugin生成時のgemspecはsummaryやdescriptionにTODOが入っており、TODOが入っているとvalidationエラーになり、bundle installが必ず失敗していまうので、デフォルトでは実行しないよう修正しています。

因みに以下のようなエラーがおきます。

You have one or more invalid gemspecs that need to be fixed.
The gemspec at /home/yaginuma/program/rails/master/blorgh/blorgh.gemspec is not valid. Please fix this gemspec.
The validation error was '"FIXME" or "TODO" is not a description'

Merge pull request #25633 from kamipo/remove_create_table_info_cache

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

再利用されてないcreate_table_info_cacheを削除しています。


Merge pull request #25631 from yahonda/revert_rename_to_ar_internal_metadata

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

既にactive_record_internal_metadatasテーブルがある場合にar_internal_metadataにテーブル名を変更するよう対応した、Rename active_record_internal_metadatas to ar_internal_metadataをrevertしています。

Rails 5.0.0もリリースされて、古いテーブルのリネーム対応はもう不要な為。


Merge pull request #24177 from vipulnsward/rename-test

nested_parameters_test.rbを内容に合わせてnested_parameters_permit_test.rbにリネームしています。テストクラス名も同様にリネーム済み。


Merge pull request #25507 from bquorning/optimize-for-first-result-and-remove-mysql-select_one

Active Recordの修正です。

Mysql2Adapterからselect_oneメソッドを削除しています。代わりにActiveRecord::Result#firstメソッドを追加しています。

今の#select_oneの実装があまり良くないのと、そもそも必要無いのでは、という理由で削除されたようです。多分。


fix task name to remove

railties/lib/rails/generators/rails/app/app_generator.rbの修正です。

AppGeneratorクラスでremoveするタスク名をタイポしていたのを修正しています。


Try the newest bundler

.travis.ymlの修正です。

テストの際に最新のbundlerを使用するよう、bundlerのバージョンを指定していたのを削除しています。


Merge pull request #25222 from vipulnsward/25219-fix-logs

railties/lib/rails/backtrace_cleaner.rbrailties/lib/rails/commands/console.rbの修正です。

IRBでもRails.backtrace_cleanerを有効に、不要なtraceが表示されないよう修正しています。


refer to rails command instead of rake in doc of SourceAnnotationExtractor [ci skip]

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

notesタスクのexampleで、rakeコマンドを使用していたのを、railsコマンドを使用するよう修正しています。


Merge pull request #25644 from Edouard-chin/forgotten-doc-removal

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

ActionView::Digestor.digestメソッドから、既に存在しないpartialオプションを削除しています。


Merge pull request #25638 from kamipo/remove_unused_predicate_builder

Active Recordの修正です。

ActiveRecord::PredicateBuilder::BasicObjectHandlerクラス及びActiveRecord::PredicateBuilder::RangeHandlerクラスから使用していないpredicate_builder変数を削除しています。


Correct guide generation command [ci skip]

guides/rails_guides/generator.rbのdocの修正です。

guideを生成するコマンドに誤りがあったのを修正しています。