なるようになるブログ

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

rails commit log流し読み(2014/05/13)

2014/05/13分のコミットです。

ActionDispatch::Routing::PolymorphicRoutesに対する大量のコミットがあったのですが、リファクタリング、かつ、同じ箇所に対する修正が複数回行われており、一つ一つのコミットが確認するのは辛かったので、割愛しています。


pg, change_column_default accepts []. Closes #11586.

PostgresqlのConnectionAdapterに関する修正です。

change_columnのdefaultに[]を指定出来るようになりました。

change_column :pg_arrays, :snippets, :text, array: true, default: []

こんな感じです。Postgresqlarray使う時ようですね。


test, use columns_hash[] in place of columns.find {}.

PostgresqlAdapterのテストの修正です。

columns.find {}でcolumnを取得していた処理を、 columns_hashを使うように修正しています。


Use block parameter rather than $1 during gsub! so ActiveSupport::SafeBuffer values aren't mangled.

ActiveSupport::NumberHelper::NumberToDelimitedConverter#partsメソッドの修正です。

number_to_delimitedメソッドが引数にActiveSupport::SafeBufferを指定された時に正常に動いてなかったのを修正しています。

html_safeメソッドを使うと、戻り値はActiveSupport::SafeBufferになるので、html_safeメソッドを使うケースではまずかったようです。


Require active_support/core_ext/string/output_safety and use html_safe rather than use non-public SafeBuffer API.

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

上記コミットのテストを、ActiveSupport::SafeBufferインスタンスを生成して行ってたのを、String#html_safeメソッドを使用するようにしています。

SafeBufferがnon-publicなAPIだからですね。


Update and add tests in array_ext_test.rb

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

to_xmlメソッドにArrayを指定した場合のテストを追加しています。


Update require in array_ext_test.rb

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

requireするファイルを整理しています。


Hash#except is expensive and this is a hotspot, so use a dup + delete

ActionDispatch::Routing::RouteSet::Generator#url_forの修正です。

Hash#exceptメソッドを使用している箇所をdup + deleteメソッドに修正しています。

Hash#except is expensiveとなっているので、処理的に重い、という事でしょうか。


make the module version quack the same as the instance

actionpack/lib/action_dispatch/routing/route_set.rbの修正です。

url_optionsメソッドを追加して、respond_to?:url_optionsの存在チェックをしないでよいように修正しています。


reduce conditionals in url_for

ActionDispatch::Routing::RouteSet::Generator#url_forの修正です。

optionsのチェック処理をリファクタリングしています。


typo: resulution -> resolution [ci skip]

rails guideのActive Record and PostgreSQLのページの修正です。

typoの修正。


flip conditional to use if/else instead of unless/else

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

unless/elseを使用していた箇所をif/elseに修正しています。

可読性の向上の為、ですかね。


This model is a model so it should behaves like one

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

extend ActiveModel::Namingしていたのを、include ActiveModel::Modelに修正しています。

modelとしての振る舞いを期待されていたクラスの為とのことです。


This is also a model

railties/test/application/configuration_test.rbの修正です。

こちらも上のコミット同様、extend ActiveModel::Namingしていたのを、include ActiveModel::Modelに修正しています。


Test with ruby-head to make @tenderlove happy

travis.ymlの修正です。テスト対象にruby-headを追加しています。


Ok. Enough models for today :rage:

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

extend ActiveModel::Namingしていたのを、include ActiveModel::Modelに修正するお仕事。


avoid array allocation when extracting usernames and passwords

actionpack/lib/action_dispatch/routing/route_set.rbの修正です。

不要なArrayの生成処理を削除しています。


fix bad merge

actionview/test/activerecord/polymorphic_routes_test.rbの修正です。

mergeミスがあったらしく、不要なテスト処理を削除しています。


Fix regression on assert_redirected_to.

actionpack/lib/action_dispatch/testing/assertions/response.rbの修正です

controllerが設定されてないときにassert_redirected_toメソッドが失敗していたのを修正しています。

controllerが設定されてないときは、ActionController::Metalインスタンスを生成しています。


A minor stylistic fix and cleanup of mail deliveries.

actionmailer/test/log_subscriber_test.rbの修正です。

ダブルクォーテーションをシングルコーテーションに修正、後処理にBaseMailer.deliveries.clear追加を行っています。


Remove unnecessary setup and teardown.

actionmailer/test/mail_layout_test.rbの修正です。

不要なsetup/teardownを削除しています。


docs, explain usage of count + select. Closes #15065. [ci skip]

ActiveRecord::Calculations#countメソッドのdocの修正です。

not all valid +select+ expressions are valid +count+ expressions.です。DBによって、動きが違うので、エラーになる事もある旨追加しています。


Move state restoration from setup/teardown into affected test cases.

actionmailer/test/delivery_methods_test.rbの修正です。

状態の保存/復旧をsetup/teardownで行うように修正しています。


Use with_translation helper to clean up I18n stored translations.

actionmailer/test/i18n_with_controller_test.rbの修正です。

テスト用のヘルパーメソッドを作成し、処理を整理しています。


test, move all pg array tests into postgresql/array_test.rb.

PostgresqlAdapterのテストの修正です。

Arrayのテストを全てactiverecord/test/cases/adapters/postgresql/array_test.rbに移動しています。


Simplify merge call on polymorphic helpers

actionpack/lib/action_dispatch/routing/polymorphic_routes.rbの修正です。

dup.merge!していたのを、mergeに修正しています。


Dup options hash to prevent modifications

ActionView::Helpers::TranslationHelper#translateメソッドの修正です。

引数のoptionsを最初にdupし、dupした値を操作するよう修正しています。

dupしないと、元々の値を壊す可能性があるからでしょうね。


Get rid of unused method

actionpack/lib/action_dispatch/routing/route_set.rbの修正です。

使わなくなったメソッドの削除。


Do not check defined?(CGI) on every call #to_query

Object#to_queryメソッドの修正です。

メソッドないで、毎回defined?(CGI)を行っていたのですが、最初にrequire 'cgi'するようにして、defined?(CGI)を削除しています。


extract pg type map initialization process to TypeMapInitializer.

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

pg_typeのデータからOID -> Type mappingを組み立てるためのTypeMapInitializerクラスを作成しています。

元々はactiverecord/lib/active_record/connection_adapters/postgresql_adapter.rbの中で行っていた処理を、別クラスに切り出したんですね。


pg, clarify default behavior for composite types.

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

Postgresqlcomposite typeを使用した際のテストケースを追加しています。