なるようになるブログ

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

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

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

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

actionview/CHANGELOG.md

actionpack/CHANGELOG.md


use Ruby for mocking

actionpack/test/controller/url_for_test.rbの修正です。

mockメソッドではなく、Classをモック代わりに使っています。

-        model = mock(:to_param => 'api')
+        model = Class.new { def self.to_param; 'api'; end }

reduce calls to named_host?

actionpack/lib/action_dispatch/http/url.rbの修正です。

named_host?メソッドの呼び出し回数を減らすリファクタリング


only extract domain from the options hash once

actionpack/lib/action_dispatch/http/url.rbの修正です。

optionsに格納されているdomainを、別変数に格納するよう修正しています。hashのルックアップを減らす為のようです。


lookup subdomain from the options hash once, defaulting to true

actionpack/lib/action_dispatch/http/url.rbの修正です。

optionsに格納されているsubdomainを、別変数に格納するよう修正しています。hashのルックアップを減らす為のようです。


[ci skip] Correct output of #assert_not

activesupport/lib/active_support/testing/assertions.rbのdocの修正です。

出力結果の例が誤っていたのを修正しています。


only check named_host? once in normalize_host

actionpack/lib/action_dispatch/http/url.rbの修正です。

named_host?のチェックを一回だけ行うようリファクタリング


Update test data which doesn't reflect expected usage

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

テストデータに"---"と"\n"を加えています。YAML encodedが正常に行われているか、の確認の為ですかね。


In tag helper, honor html_safe on array parameters; also make safe_join more similar to Array.join by first calling flatten.

actionview/lib/action_view/helpers/output_safety_helper.rbactionview/lib/action_view/helpers/tag_helper.rbの修正です。

safe_joinメソッドArray#flattenを呼び出すよう修正しています。

# before 
  helper.safe_join(['a',['b','c']], ':')  # "a:["b", "c"]"

# after 
  helper.safe_join(['a',['b','c']], ':')  # "a:b:c"

Merge pull request #15667 from samdec/mailer_doc_bug_fix

rails guideのAction Mailer Basicsの修正です。

exampleが誤っていたのを修正しています。


Fix performance regression on preloading HABTM associations

activerecord/lib/active_record/attribute_methods/primary_key.rbactiverecord/lib/active_record/core.rbの修正です。

HABTM associationsで性能劣化があったのを修正しています。

early returnの追加、hashメソッド改修を行っています。コミットログ見る限り、まだ性能に問題があるとの事。


Defer to super, rather than re-implementing Object#hash

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

先ほど修正したhashメソッドを再修正しています。idnilだった場合、superで親クラスよんでいます。


Use a conditional rather than early return in id

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

先ほどearly return入れた処理を再度修正しています。early returnやめて、if条件にしています。


Add a test to ensure we don't get a performance regression on #hash

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

性能改善確認用のテストコードを追加しています。


Add missing test cases for #assert_no_difference

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

assert_no_differenceメソッドについてのテストを追加しています。


[ci skip] BigDecimal#duplicable? returns false in 1.9.x

activesupport/lib/active_support/core_ext/object/duplicable.rbのdocの修正です。

duplicable?メソッドRuby1.9.x系だとBigDecimalクラスでfalseを返すので、そのむね説明を追加しています。


Set flash in test session when necessary.

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

flashの値があった時だけ、sessionに値を設定するよう修正しています。


Set the status before of setting the response body

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

response_bodyより先に、statusコードを設定するよう修正しています。

-        controller.response_body = "HTTP Basic: Access denied.\n"
         controller.status = 401
+        controller.response_body = "HTTP Basic: Access denied.\n"

ActionController::Liveを使用している場合、response_bodyが返ってきたタイミングでcloseしてしまうので、statusコードが取得出来ないケースがあるようです。


pg guide, minor copy edits

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

細かな言い回し等の修正を行っています。


Fix parsed token value with header Authorization token=. actionpack/lib/action_controller/metal/http_authentication.rbの修正です。

auth headerにAuthorization: Token token=という値が設定されていた場合、tokenは空なのでnilを返すべきところなのですが、tokenという文字列を返してしまっていたバグを修正しています。


PG arrays should type cast user input

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

ユーザが設定したArrayをtype castするよう修正しています。