なるようになるブログ

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

rails commit log流し読み(2014/07/31)

2014/07/31分のコミットです。

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

actionmailer/CHANGELOG.md


Deprecate *_path methods in mailers

mailersで*_pathメソッドはdeprecateになりました。代わりに、 *_urlを使用するようにとの事です。

そもそもメール文中に相対パスで記載するのはおかしいので、絶対パスで書こうね、との事で。


Prevent using String#scrub on Rubinius

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

Rubiniusの場合、String#scrubを使用しないよう対応しています。String#scrubメソッド自体はあるらしいのですが、ASCII外文字は対応していない為との事です。


Remove redundant self. in class method calls

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

不要なself.を削除しています。


add will remove the method if it exists already

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

define_url_helperメソッド内でremove_possible_methodを行っていたのを削除しています。何故、かは良く解らない…。この処理に来る前に削除されているからなのかなあ。


split path_helpers and url_helpers

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

元々helpers変数にpath_helpersとurl_helpers両方保持していたのを、それぞれ別変数に保持するようリファクタリングしています。処理がスッキリして良い感じです。


fix variable name

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

変数名をroute_methods->url_helpersに修正しています。


avoid instrospection on the module

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

instance_methodsを使用して取得していたpath_helpersの情報を、メソッドを使用せず、先程のコミットで対応した変数を使用するよう修正しています。


remove alias_method_chain

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

不要なalias_method_chainを削除しています。


don't access named routes internals

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

routingが設定済みかどうかを確認するのに、route_defined?メソッドを使用するよう修正しています。


Removed unnecessary call to 'convert_key' in 'HashWithIndifferentAccess#to_hash'

HashWithIndifferentAccess#to_hashメソッドの修正です。

不要なconvert_key処理を削除しています。keyは全てStringに変換済みなので、不要との事です。


turn scope in to a linked list

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

scope格納用にScopeクラスを新設し、連結リストでデータを保持するよう修正しています。


push options inside the scope object

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

SCOPE_OPTIONSを先程作成したScopeクラス配下に格納するよう修正しています。


remove useless deup

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

不要なdupメソッドを削除しています。


Remove some globals from configuration tests

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

グローバル変数に設定していた値を、Rails.configuration配下の変数に設定するよう修正しています。


Fix / improve some assertions

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

適切なassertメソッドを使用したり、assert_equalの引数の順番が誤っていたのを修正しています。

そもそもこのテスト、assert_equalではなく、assertassert_notを使用した方がテストが明確になる気が。


Remove some more globals from tests

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

グローバル変数をローカル変数に変更しています。そもそもグローバルである必要が無かった感じです。


Invert unless..else conditions on JRuby checks

railties/test/generators/app_generator_test.rbの修正です。

JRubyのチェック処理でunless..elseを使用していたのをif..elseに修正しています。if..elseの方が分り易い、という判断何ですかね。


Simplify plugin tests a bit, leave the regexp work for minitest

railties/test/generators/plugin_generator_test.rbの修正です。

テスト内で行っていたRegexp.escapeを削除しています。assert_matchメソッドRegexp.escape無しでも正常に動作する為のようです。


Simplify path setup

railties/test/generators/generators_test_helper.rbの修正です。

file load処理を修正しています。

-      @root ||= File.expand_path(File.join(File.dirname(__FILE__), '..', 'fixtures'))
+      @root ||= File.expand_path('../../fixtures', __FILE__)

個人的には修正前の方が好みですねえ。


Use default argument when testing generators without the need for extra args

railties/test/generators/app_generator_test.rbの修正です。

run_generator呼び出し時に設定していた引数を削除しています。デフォルト引数で問題無い箇所についてのみ対応しているようです。


Avoid defining the test if it does not need to when not on JRuby

railties/test/generators/app_generator_test.rbの修正です。

JRubyのチェック処理をメソッド定義の外側で行うよう修正しています。

-  def test_config_jdbc_database_when_no_option_given
-    if defined?(JRUBY_VERSION)
+  if defined?(JRUBY_VERSION)
+    def test_config_jdbc_database_when_no_option_given

Properly assert for the expected messages

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

エラーがraiseされたかどうか確認していたのを、エラーメッセージの内容を確認するよう修正しています。

-      assert_raise ArgumentError, "Nil location provided. Can't build URI." do
+      exception = assert_raise ArgumentError do
         polymorphic_url(nil)
       end
+      assert_equal "Nil location provided. Can't build URI.", exception.message

本来やりたかった事はこっちな気がします。


Raise a descriptive error if non-positive integer passed to in_groups_of.

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

Array#in_groups_ofに0以下の値を設定した場合に、ArgumentErrorをおこすよう修正しています。

[1, 2, 3].in_groups_of(0)
# =>ArgumentError: Group size must be a positive integer, was 0

エラーが明確で分り易くなってますね。


Add tests to ensure default proc is used when `HashWithIndifferentAccess' is initialized with a block

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

HashWithIndifferentAccessコンストラクタにブロックを指定した場合のテストケースを追加しています。


Remove unnecessary call to #tap

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

ActionDispatch::Routing::RouteSetを生成している箇所で不要なtapメソッドを削除しています。


Avoid creating an extra hash

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

不要なHash生成処理を行わないよう修正しています。


Fix assertion arguments order

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

test_does_not_attach_private_methodsテストで、assertの引数の順番が誤っていたのを集成しています。


Avoid a new hash object

actionpack/lib/action_controller/metal/url_for.rbの修正です。

不要なHash生成処理を行わないよう修正しています。mergeではなく、`merge!を使用するようにしています。


Simplify code branch, remove #tap

actionpack/lib/action_controller/metal/url_for.rbの修正です。

tapメソッドを削除し、値を変数に格納するよう修正しています。

- @_url_options.dup.tap do |options|
+ options = @_url_options.dup

インデントが一つ減っているので、ちょっと見通しは良くなかったかと。