なるようになるブログ

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

rails commit log流し読み(2015/02/13)

2015/02/13分のコミットです。

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

activerecord/CHANGELOG.md

actionpack/CHANGELOG.md

activemodel/CHANGELOG.md


Merge pull request #18885 from ypxing/master

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

halting_and_conditionalメソッドのコールバック処理内で行っていた、不要な変数への代入処理を削除しています。


Merge pull request #18886 from kamipo/allow_precision_option_for_time_column

ActiveRecordの修正です。

time 型のカラムにprecisionオプションを指定出来るよう対応しています。


Merge pull request #11790 from printercu/patch-3

actionpack/lib/abstract_controller/translation.rbの修正です。

ActionController#translateの引数にSymbolを渡せるよう対応しています。

t(:'.no_action')

こんな形で渡せるようになっています。


Merge pull request #18844 from yuki24/guides-add-render-example-without-partial-and-locals

rails guideのAction View Overviewの修正です。

renderメソッドpartial及びlocalsオプションを渡さずに使用する場合の説明を追加しています。


Extract DateTimePrecisionTest

ActiveRecordの修正です。datetime precisionについてのテストが各adapters毎に同じ内容が定義されてしまっていたので、重複しているテストをDateTimePrecisionTestクラスに切り出しています。


Optimize none? and one? relation query methods to use LIMIT and COUNT.

ActiveRecordの修正です。

blocklimitが指定されてない場合に、none?メソッドLIMIT 1を、one?メソッドCOUNTをそれぞれ使用するよう修正しています。

# Before:
users.none? # =>  SELECT "users".* FROM "users"
users.one?  # =>  SELECT "users".* FROM "users"

# After:
users.none? # =>  SELECT 1 AS one FROM "users" LIMIT 1
users.one?  # =>  SELECT COUNT(*) FROM "users"

Skip url_helpers instead of caching, speed up integration tests

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

integration testでurl_helpersの値をキャッシュしていたのを止めて、代わりにrespond_to?の結果をメモ化するよう修正しています。性能改善の為。


use before_setup to set up test instance variables

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

インスタンス変数の生成処理をbefore_setup内で行うよう修正しています。


lazily create the integration session

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

必要になった際にintegration_sessionを生成するよう修正していまう。合わせて、不要になったsessionのreset処理を削除しています。


there is always an integration session, so remove the check

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

copy_session_variables!メソッドから@integration_sessionのチェック処理を削除しています。


remove meta programming

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

instance_variable_setメソッドで行っていたインスタンス変数への値の設定処理を、普通の代入式を使用するよう修正しています。

記述の為の行数が変わらないし、また、メタプロ無しの方が速い為との事。


require rack/utils in exception_wrapper

actionpack/lib/action_dispatch/middleware/exception_wrapper.rbの修正です。

不足していたrack/utilsのrequireを追加しています。


[ci skip] escape under score

rails guideのAction Controller Overviewの修正です。

Other Ways to Use Filtersの項で、_へのエスケープが足りてなかったので、追加しています。


Do not recommend xhr since it is going to be deprecated.

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

ActionDispatch::IntegrationTestのHTTP request methodsでキーワード引数を使用していない場合に出力されるwarningメッセージに、deprecateになったxhrメッセージをが含まれていたので、削除しています。


Improve deprecation message.

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

ActionDispatch::IntegrationTestのHTTP request methodsでキーワード引数を使用していない場合に出力されるwarningメッセージに、使用出来るキーワード引数の一覧を表示するよう修正しています。


Merge pull request #18918 from morgoth/do-not-overwrite-value-of-secret-token-when-present

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

既にtokenに値が設定されている場合に、has_secure_tokenメソッドが既存の値を上書きしないよう修正しています。

user = User.create(token: "custom-secure-token")
user.token # => "custom-secure-token"

remove CHANGELOG entry for Rails 5.0 only feature. #18918

activerecord/CHANGELOG.mdの修正です。

既にリリース済みのhas_secure_tokenメソッドについてCHANGELOGに記載されていたのを、削除しています。


Correct module name in deprecation message.

ActionDispatch::IntegrationTestのHTTP request methodsでキーワード引数を使用していない場合に出力されるwarningメッセージで出力されるモジュール名に誤りがあったのを修正しています。


Merge pull request #16381 from kakipo/validate-length-tokenizer

activemodel/lib/active_model/validations/length.rbの修正です。

LengthValidatortokenizeオプションにメソッド名を指定出来るよう対応しています。

class Article
  include ActiveModel::Model

  validates_length_of :content,
    minimum: 10,
    message: "must be at least 10 words",
    tokenizer: :tokenize_by_words

  def tokenize_by_words(text)
    text.scan(/\w+/)
  end
end