なるようになるブログ

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

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

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

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

activesupport/CHANGELOG.md

actionmailer/CHANGELOG.md


Merge pull request #16303 from rajcybage/removing_master

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

使用していないメソッドがあるのですが、そのメソッドがRack SPECで必要な旨追加コメントを追加しています。

RackのSPECはこちら


docs, clarify attribute query methods on numeric columns. Closes #16246.

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

numericカラムについて、0じゃない場合にpresentが定義される旨説明を追加しています。


Fix typo and remove code block since present is not a method.

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

先のコミットでtypoがあったのを修正しています。


Transactions refactoring

ActiveRecordのtransaction処理のリファクタリングです。

トランザクションの状態を管理する為のTransactionManagerクラスを新設に、トランザクション関係の処理はそちらに集約しています。


savepoint_name should return nil for non-savepoint transactions

ActiveRecordのtransaction処理の修正です。

savepoint transactionじゃない場合、savepoint_nameメソッドnilを返すよう修正しています。


Extract the transaction class to a local variable

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

transactionsクラスをローカル変数に格納しています。

-        transaction =
-          if @stack.empty?
-            RealTransaction.new(@connection, current_transaction, options)
-          else
-            SavepointTransaction.new(@connection, current_transaction, options)
-          end
+        transaction_class = @stack.empty? ? RealTransaction : SavepointTransaction
+        transaction = transaction_class.new(@connection, current_transaction, options)

ちょいリファクタリング


remove some caching

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

optimize_routes_generation?メソッドでインスンタンス変数に値をキャッシュしていたのを止めています。

-        return @_optimized_routes if defined?(@_optimized_routes)
-        @_optimized_routes = _routes.optimize_routes_generation? && default_url_options.empty?
+        _routes.optimize_routes_generation? && default_url_options.empty?

このキャッシュは性能の改善にはならないのに、複雑になってしまっているので、キャッシュを削除したとの事です。


remove the mounted? method

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

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


remove blank lines in the start of the ActiveRecord files

ActiveRecordの各ファイルの先頭にあった不要な空行を削除しています。


Move object test files under object

Objectクラスのテストをactivesupport/test/core_ext/object/配下に移動しています。


Give password_confirmation div the "field" class in erb form template

railties/lib/rails/generators/erb/scaffold/templates/_form.html.erbの修正です。

scaffoldで生成されるtemplateからclass="field"が漏れていたのを追加しています。


Added failing test case for #16131

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

ojmulti_jsonと一緒にactive_support/core_ext/objectを使用した際に、エラーになる問題があったらしく、その確認の為のテストを追加しています。


Fixed a compatibility issue with the Oj gem

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

先にテストを上げた問題について対応しています。

active_support/jsonをloadせずにactive_support/core_ext/object/jsonを使用した場合に問題があったようです。

-    if ActiveSupport.use_standard_json_time_format
+    if ActiveSupport::JSON::Encoding.use_standard_json_time_format

active_support/jsonがロードされるよう、autoloadのトリガーを修正しています。


Raise an exception when attachments are added after mail was called.

actionmailer/lib/action_mailer/base.rbの修正です。

mailメソッドを呼び出した後にattachmentsを設定した場合にRuntimeErrorがraiseされるよう対応しています。

class LateAttachmentMailer < ActionMailer::Base
  def welcome
    mail body: "yay", from: "welcome@example.com", to: "to@example.com"
    attachments['invoice.pdf'] = 'This is test File content'
  end
end

上記のようなケースがエラーになるようになっています。そもそも、正常に動作してなかったので、問題がを起きている事を明確にする為に、Errorを起こすようにしたようです。

class LateAttachmentAccessorMailer < ActionMailer::Base
  def welcome
    attachments['invoice.pdf'] = 'This is test File content'
    mail body: "yay", from: "welcome@example.com", to: "to@example.com"
  end
end

attachmentsが先のケースは当然OKです。


[ci skip] fix doc typo for validates_uniqueness_of

activerecord/lib/active_record/validations/uniqueness.rbのdocの修正です。

typoを修正しています。


Move array test files under array

activesupport/test/core_ext配下にあったArray関係のテストをactivesupport/test/core_ext/array配下に移動しています。


docs, cleanup mixed indents within form_options_helper.rb RDoc.

actionview/lib/action_view/helpers/form_options_helper.rbのdocの修正です。

不要なスペースの削除、インデントの整理等々を実施しています。


Add missing test case for Array#to_sentence, collect all test cases for Object#to_param at one place and avoid repitition

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

Array#to_sentenceメソッドのテストが無かったのを追加しています。合わせて、Object#to_paramメソッドのテストを適切な箇所に移動しています。


Remove @state.parent assignment on commit

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

@state.parentに値を設定する処理を削除しています。

元々はコミットがされたかどうかのチェックに使用していたようなのですが、こちらのコミットから使用されなくなったので、削除したようです。