なるようになるブログ

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

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

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

CHANGELOGへの追加はありませんでした。


Work around all the things

actioncable/test/client_test.rbの修正です。

Pumaを使用してテストを行う際に、テストの後処理でIOErrorが発生した場合の対応を追加しています。

      begin
         thread.join
+
+      rescue IOError
+        # Work around https://bugs.ruby-lang.org/issues/13405
+        #
+        # Puma's sometimes raising while shutting down, when it closes
+        # its internal pipe. We can safely ignore that, but we do need
+        # to do the step skipped by the exception:
+        server.binder.close

既にcloseされているstreamに対してIO#closeを行った場合に、IOErrorが発生してしまう事がある(通常は無視されるが、Ruby側のバグで発生してしまうケースがある)為、その影響で処理が終了してしまわないようにする為に対応を追加したようです。

参考:Bug #13405: IO#close raises “stream closed”

rails commit log流し読み(2017/04/05)

2017/04/05分のコミットです。

CHANGELOGへの追加はありませんでした。


Downplay links in Guides headers

guides/assets/stylesheets/main.cssの修正です。

Rails guideのheaderのリンクの色を灰色に変更しています。

image

通常のページ内のリンクを目立たせる為に、headerのリンクの色は灰色したとの事です。


Don’t highlight code in anchorlink [ci skip]

guides/assets/stylesheets/main.cssの修正です。

header titleにコードが含まれていても、そのコードはハイライトされないよう修正しています。

Before:

image

After:

image


Avoid “can’t modify frozen IOError” failures https://github.com/rails/rails/commit/c866cf9df8b7d767f8be8272b120b44f453212cb

actioncable/test/client_test.rbの修正です。

テスト用スレッドの後処理で、can't modify frozen IOErrorが発生した場合の対応を追加しています。

-    t = Thread.new { server.run.join }
-    yield port
+    thread = server.run

-  ensure
-    server.stop(true) if server
-    t.join if t
+    begin
+      yield port
+
+    ensure
+      server.stop
+
+      begin
+        thread.join
+      rescue RuntimeError => ex
+        raise unless ex.message =~ /can't modify frozen IOError/
+
+        # Work around https://bugs.ruby-lang.org/issues/13239
+        server.binder.close
+      end
+    end

ensure / rescue句でstreamのclose処理を行う際に、RuntimeError: can't modify frozen IOErrorが発生してしまうバグがRuby本体で発生しており、そのワークアラウンドとして対応したとの事です。

参考:Bug #13239: Bug with “special exceptions” when they are thrown in context of a rescue clause.


Use appropriate type to header option

railties/lib/rails/commands/dbconsole/dbconsole_command.rbの修正です。

dbconsoleheaderオプションのtypeにstringを指定していたのを、booleanに修正しています。headerオプションは引数を指定出来ないオプションである為。


Ignore AR tests of index comment when using Oracle

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

Oracle adapterではINDEXにCOMMENTを設定するテストを行わないよう修正しています。OracleではINDEXへのCOMMENTの追加は出来ない為。

rails commit log流し読み(2017/04/04)

2017/04/04分のコミットです。

CHANGELOGへの追加はありませんでした。


Revert “Merge pull request #28598 from wnadeau/patch-1”

forty_twoメソッドのdocのコメントを修正した、FinderMethods#fourty_two docs cite proper sourceをrevertしています。

-    # Find the forty-second record. Also known as accessing "the answer to life the universe and everything".
+    # Find the forty-second record. Also known as accessing "the reddit".

意図的に(ジョークとして)redditとしていたので、そのままの方が良いだろう、という事でrevertしたとの事です。この辺りのニュアンスはよくわからない…。


Merge pull request #28029 from koic/empty_insert_statement_value_not_supported

activerecord/test/cases/dup_test.rbactiverecord/test/cases/primary_keys_test.rbの修正です。

test_dup_without_primary_key及びtest_create_without_primary_key_no_extra_queryのテストを、Oracle adapterの場合実行しないよう修正しています。

Oracle adapterではempty_insert_statement_valueメソッドを実装していない(OracleINSERT .. DEFAULT VALUESが使えない)為、上記テストがエラーになってしまう為、実行しないようにしたとの事です。

詳細はこちらのコメント参照。


Merge pull request #28057 from eugeneius/clear_active_connections

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

Railsの初期化処理でactive connectionsをclearするよう修正しています。

初期化処理時に使用したconnectionsを再利用出来るようにする為(初期化処理とリクエストを処理するスレッドが異なる場合にconnectionsを使いまわせなくなってしまうのを避ける為)、との事です。


Merge pull request #27832 from bdewater/backtrace-silencer-regex

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

backtrace cleanerで!~の代わりにRegexp#match?を使用するよう修正しています。

rails commit log流し読み(2017/04/03)

2017/04/03分のコミットです。

CHANGELOGへの追加はありませんでした。


CI against Ruby 2.4.1

.travis.ymlの修正です。

CIで使用するRubyのバージョンが一部2.4.0のままになっていたのを、2.4.1に更新しています。

rails commit log流し読み(2017/04/02)

2017/04/02分のコミットです。

CHANGELOGへの追加はありませんでした。


Limit stale checks to issues

probot-stateがissuesだけをチェックするよう設定を修正しています。

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


Remove CHANGELOG.md entry that appears in 5-1-stable

activerecord/CHANGELOG.mdの修正です。

ActiveRecord::Relation#inspectメソッドが毎回必ずrecordsのload処理を行っていたのを、既にrecordsをload済みの場合、load済みの値を使用するよう修正した対応のエントリーを削除しています。Rails 5.1ブランチにバックポートされており、5.2の新規対応では無いため。


No need to check nil

activemodel/lib/active_model/attribute_assignment.rbの修正です。

AttributeAssignment#assign_attributesメソッドから不要なnilチェックを削除しています。

      if !new_attributes.respond_to?(:stringify_keys)
         raise ArgumentError, "When assigning attributes, you must pass a hash as an argument."
       end
-      return if new_attributes.nil? || new_attributes.empty?
+      return if new_attributes.empty?

new_attributesnilだった場合、直前のnew_attributes.respond_to?(:stringify_keys)の方のチェックにひっかかりArgumentErrorがraiseされている為。


Merge pull request #28641 from diazruy/anchors

guides/assets/stylesheets/main.cssguides/rails_guides/markdown.rbの修正です。

rails guideのページ内の全ヘッダーにanchor linkを追加しています。


Avoid broken faraday 0.12.0 release

Gemfileの修正です。

faradayのバージョンを0.11系を使用するよう固定しています。

faraday 0.12.0をダウンロードしようとするとチェックサムのチェックに引っかかりエラーになってしまう為。

参考:checksum does not match for faraday 0.12.0 gem

しかしすぐ0.12.0.1 がリリースされて、問題が解決された為、後ほどrevertされています。


Revert “Avoid broken faraday 0.12.0 release”

という訳で、直前のfaradayのバージョンを0.11系を使用するよう修正したコミットをrevertしています。

rails commit log流し読み(2017/04/01)

2017/04/01分のコミットです。

CHANGELOGへの追加はありませんでした。


Add default_scope note to AR guide [ci skip]

rails guideのActive Record Query Interfaceの修正です。

Applying a default scopeの項に、scope argumentにArrayを渡した場合とHashを渡した場合の挙動の違いについての説明を追加しています。

class Client < ApplicationRecord
  default_scope { where(active: true) }
end

Client.new          # => #<Client id: nil, active: true>
Client.unscoped.new # => #<Client id: nil, active: nil>


class Client < ApplicationRecord
  default_scope { where("active = ?", true) }
end

Client.new # => #<Client id: nil, active: nil>

rails commit log流し読み(2017/03/31)

2017/03/31分のコミットです。

CHANGELOGへの追加はありませんでした。


Fix example usage of ActiveRecord::Base.establish_connection

activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rbのdocの修正です。

establish_connectionメソッドを使用したexampleコードで、引数にStringを使用していたのをSymbolを使用するよう修正しています。named connectionを指定したい場合はSymbolを指定する必要がある為。


Restore rails-ujs.js UMD module support

actionview/Rakefileの修正です。

rails-ujs.jsのUMD module supportの為に、compile task実行時にsprockets/exportをrequireするよう修正しています。

合わせて、コンパイルされたJSが正常に動作する事を確認する為のrake taskも追加しています


Reorganize rails-ujs files

rails-ujsの修正です。

rails-ujs用JSファイルのディレクトリ構成、エントリーポイント用JSの追加、等をまとめて行っています。


Merge pull request #28607 from mikeastock/move-hash-with-indifferent-access-test

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

HashのテストとHashWithIndifferentAccessのテストが同じファイルにまとめられていたのを、HashWithIndifferentAccessのテストについては別ファイルに切り出すよう修正しています。


Small grammar fix

rails guideのRails Routing from the Outside Inの修正です。

Non-Resourceful Routesの項のグラマーの修正を行っています。


Add missing backtick to deprecation message

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

Dirty#attribute_will_change!メソッドで出力するdeprecateメッセージにバッククォートが不足していたのを修正しています。


CI against Ruby 2.3.4

.travis.ymlの修正です。

CIで使用するRubyのバージョンを2.3.3から2.3.4に更新しています。


Fix a failed AR test when running with OracleAdapter

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

abstract class + default scopeのテストがOracleAdapterでコケていたのを修正しています。


Correct typo in component name

actionview/Rakefileの修正です。

Action Viewのassetsのverify用のtaskのdescがVerify compiled Action Cable assetsになっていたのを、Verify compiled Action View assetsに修正しています。