なるようになるブログ

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

rails commit log流し読み(2014/09/11)

2014/09/11分のコミットです。

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

activerecord/CHANGELOG.md

activesupport/CHANGELOG.md


i18n guide: clarify interpolation rules in _html keys [ci skip]

rails guideのRails Internationalization (I18n)の修正です。

ymlに組み込みの値設定するやり方についてのサンプルを追加しています。

en:
  welcome_html: "<b>Welcome %{username}!</b>"

you can safely pass the username as set by the user:

<%# This is safe, it is going to be escaped if needed. %>
<%= t('welcome_html', username: @current_user.username %>

Replace drop sql statement to drop_table method

ActiveRecordのテストの修正です。

tableをdropする際、SQLで行っていたのをdrop_tableメソッドを使用するよう修正しています。


Merge pull request #16867 from yahonda/use_drop_table_to_drop_sequences


Merge pull request #16379 from JackDanger/update-preloader-documentation

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

Associationsの説明が大分古いままになっており、現在の仕様に合わせた内容に修正しています。


ActiveJob Integration Tests

ActiveJobのIntegrationテストを追加しています。 redis等の外部システムとの連携もあるので、中々大変そうな感じです…。


MySQL: correct LONGTEXT and LONGBLOB limits from 2GB to their true 4GB

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

MySQLのLONGTEXT、LONGBLOB型のlimitを2GB->4GBに修正しています。

MySQLのdocを見る限り、どちらも最長4GBとなっているので、単純に間違えていたようですね。


MySQL: schema.rb now includes TEXT and BLOB column limits.

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

MySQLのTEXT、BLOBカラムについても、limitを設定するよう対応しています。 どちらも65535です。こちらもMySQLのdocにちゃんと記載ありますね。


Include default column limits in schema.rb https://github.com/rails/rails/commit/2c76793f087e212ff4c6d835656a9a95c8bfeaa5


Speed up schema dumper tests

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

schemaのダンプ処理は、最初のテストのみ行い以降はその値を使いますよう修正しています。

テスト高速化の為ですね。ただ、テスト実行順に依存しちゃいそうな。


Merge pull request #16839 from chancancode/default_test_order

テストの実行順を設定する為のオプションとして、active_support.test_orderが追加されました。

  # config/environments/test.rb
  Rails.application.configure do
    config.active_support.test_order = :sorted
  end

4.2ではデフォルトがsortedとなっており、5系ではrandomに変わる予定との事です。minitestの変更を受けて、ですかね。


Fix typo

rails guideのA Guide for Upgrading Ruby on Railsの修正です。

lockinglockに修正しています。typo


Set the test order to be random in the generated app

railties/test/isolation/abstract_unit.rbの修正です。

generateするappにconfig.active_support.test_order = :randomを設定するよう修正しています。


Set test order in ActiveSupport::TestCase of isolation/abstract_unit

railties/test/isolation/abstract_unit.rbの修正です。

self.test_order = :sortedを設定しています。


Define the configuration at Active Support

ActiveSupportの修正です、

test_orderの値をActiveSupportクラスで保持するよう修正しています。


Always define capture to remove the deprecation message

railties/test/abstract_unit.rbの修正です。

unless defined?(:capture)を削除しています。

元々のcaptureメソッドはdeprecate対象の為、使おうとすると毎度warningが出力されてしまうので、それを避ける為に、強制的にメソッド再定義するよう対応したようです。


A NullRelation should represent nothing. Closes #15176.

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

NullRelationが必ず空の値を返すよう修正しています。

PRから抜粋。

# before
Parent.listings.where(id: Listing.none).count => all_record_count

# after :
Parent.listings.where(id: Listing.none).count => 0

確かに、noneを使用しているのに、値が返ってくるのは、想定外な感じの気がします。


switch assert_operator arguments as discussed in #16860.

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

assert_operatorメソッドの引数の順番が誤っていたのを修正しています。


Changes puts to logger.info

rails guideのThe Asset Pipelineの修正です。

サンプルでputsメソッドを使用していたのをlogger.infoを使用するよう修正しています。


reuse view test-cases for pg materialized view tests.

activerecord/test/cases/adapters/postgresql/view_test.rbの修正です。

materialized viewのテストで、一度作成したviewを使いまわすよう修正しています。

"materialized view"というのを知らなかったのですが、集約や集計系の処理をする際に使われる機能で、ビューから取得できるデータの実体を持つ(materialized)ビューの事何ですね。

ビューから取得できるデータを実体として保持しておく事が出来るらしいので、ビューへの問い合わせが高速出来るらしいです。詳しくはこちらの記事ご参考。


pg, add test cases for updateable views.

activerecord/test/cases/adapters/postgresql/view_test.rbの修正です。

updateable viewsについてのテストを追加しています。