なるようになるブログ

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

rails commit log流し読み(2016/09/24)

2016/09/24分のコミットです。

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

activerecord/CHANGELOG.md

railties/CHANGELOG.md

activesupport/CHANGELOG.md


Add #25546 and #25817 to changelog [ci skip]

actionpack/CHANGELOG.mdの修正です。

#fresh_when#stale?でEtagを生成する際、templateオプションにfalseが指定されていた場合Etagにtemplate digestの値を含まないよう修正した対応(Fix adding implicitly rendered template digests to ETags)、及び、ETag用のtemplate digestを作成する際に、controlerのnamespaceが考慮されないバグがあったのを考慮されるよう修正した対応(Fix adding implicitly rendered namespaced template digests to ETags)について、CHANGELOGにentryを追加しています。


Merge pull request #26563 from knugie/fix_issue_26430

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

active_support/deprecationのrequireが不足していたので追加しています。


Serialize JSON attribute value nil as SQL NULL, not JSON 'null'

activerecord/lib/active_record/type/internal/abstract_json.rbの修正です。

JSON typeを使用していた場合に、valueがnilだった場合にJSONの"null"(ただの"null"という文字列)として値が扱われていたのを、SQLNULLとして扱うよう修正しています。


Fix docs for allowed params to get in controller tests [ci skip]

rails guideのA Guide to Testing Rails Applicationsの修正です。

Functional Tests for Your Controllersの項にあるexampleコードでgetメソッドの引数にアクション名を指定していたのを、URLを指定するよう修正しています。

-get :show, params: { id: 12 }, headers: { "HTTP_REFERER" => "http://example.com/home" }
+get article_url, params: { id: 12 }, headers: { "HTTP_REFERER" => "http://example.com/home" }

テストの親クラスにActionController::TestCaseクラスを使用している場合はアクション名を指定出来るのですが、Rails 5.0ではcontroller testの親クラスにActionDispatch::IntegrationTestを使用するようになり、アクション名を指定しての処理は行えない為。


Only search fixture_path for files that can't be found directly

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

fixture_file_uploadメソッドでfixture_pathpathの連結を行う際に、pathにファイルが存在しない場合のみ連結処理を行うよう修正しています。

    def fixture_file_upload(path, mime_type = nil, binary = false)
-      if self.class.respond_to?(:fixture_path) && self.class.fixture_path
+      if self.class.respond_to?(:fixture_path) && self.class.fixture_path &&
+          !File.exist?(path)
         path = File.join(self.class.fixture_path, path)
       end

path絶対パスを指定された場合に、不要なfixture_pathが連結されてしまうのを防ぐ為、との事です。


switch to autorun to support after_run and patch less

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

test runnerで、Minitest.runを直接呼び出してテストを実行していたのを、minitest/autorunをrequireしてテストを実行するよう修正しています。

-exit Minitest.run(ARGV)
+require "minitest/autorun"

Minitest.after_run hookが実行されるようにする為、との事です。


Fix ActiveSupport::TimeWithZone#in

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

ActiveSupport::TimeWithZone#inサマータイム考慮した値を返していなかったのを、サマータイムを考慮した正しい値を返すよう修正しています。

# before
Time.zone = "US/Eastern"
t = Time.zone.local(2016,11,6,1)
# => Sun, 06 Nov 2016 01:00:00 EDT -04:00
t.in(1.hour)
# => Sun, 06 Nov 2016 02:00:00 EST -05:00
# after
Time.zone = "US/Eastern"
t = Time.zone.local(2016,11,6,1)
# => Sun, 06 Nov 2016 01:00:00 EDT -04:00
t.in(1.hour)
# => Sun, 06 Nov 2016 01:00:00 EST -05:00