なるようになるブログ

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

rails commit log流し読み(2014/12/30)

2014/12/30分のコミットです。

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

activerecord/CHANGELOG.md

actionview/CHANGELOG.md

actionmailer/CHANGELOG.md


Just check if the buffer exists before changing it

activesupport/lib/active_support/core_ext/string/output_safety.rbの修正です。

先日行われたhtml_safenilチェックのリファクタリングを行っています。

-          unless new_safe_buffer.respond_to?(:frozen?) && new_safe_buffer.frozen?
+
+          if new_safe_buffer

frozenチェックはやめて、ifでの判定だけにしています。


eager_load preserves readonly flag for associations

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

eager_loadをした際、associationのreadonly flagを保持するよう修正しています。


plugin's gemfile also needs tzinfo-data in Windows

railties/lib/rails/generators/rails/plugin/templates/Gemfileの修正です。

Windowsの場合、Gemfileにtzinfo-dataを追加するよう修正しています。


Add nodoc to touch at no_touching.rb

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

touchメソッドに:nodoc:を追加しています。


Rely on the injectable type caster for arel_table

ActiveRecordの修正です。

Arel::Tableインスタンス生成時に、type_casterを設定するよう修正しています。

DBからの型変換処理を呼び出すのはarel側にして、ActiveRecord側は変換処理を定義したクラスを渡す形にしています。


Extract an explicit type caster class

ActiveRecordの修正です。

TypeCaster::ConnectionTypeCaster::Mapクラスを新規に作成しています。

型変換処理用のクラスですかねえ。


Fix failing tests

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

先の対応でコケたテストを修正しています。


Pass a type caster when aliasing tables for joins

ActiveRecordの修正です。

Arel::Tableのインスタンスを作成する際に、TypeCasterを渡すよう修正しています。


Remove all cases of manuallly wrapping Arel::Nodes::Quoted

ActiveRecordの修正です。

値をArel::Nodes::Quotedでラップしていた箇所をすべて削除しています。

Arel Tableにtype casterを渡すようにしたので、こちらの対応は不要との事です。


Require Arel 7.0.0.alpha

activerecord/activerecord.gemspecの修正です。

使用するarelのバージョンを7.0.0.alphaに修正しています。


Ensure first! and friends work on loaded associations

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

loadしたassociationに対してfirst!メソッドを呼び出した際に、NoMethodErrorになってしまうバグがあったのを修正しています。second!third!等も同様との事です。


Remove some warning with Ruby 2.2

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

Ruby 2.2で"unused literal ignored"が出てたのを対応しています。

-      '# This wont be added'
+      _ = '# This wont be added'# assignment to silence parse-time warning "unused literal ignored"

Un-inline if statement

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

ActionMailer::Base.register_interceptorのexampleが、一行で記載するには長すぎるとの事で、複数行に分けています。

-ActionMailer::Base.register_interceptor(SandboxEmailInterceptor) if Rails.env.staging?
+if Rails.env.staging?
+  ActionMailer::Base.register_interceptor(SandboxEmailInterceptor)
+end

Removed Object#itself as it's implemented in ruby 2.2

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

Object#itselfを削除しています。Ruby 2.2で同名のメソッドがあるからですね。


Rephrase functional testing in its relation to Rails Controller Unit Testing.

rails guideのA Guide to Testing Rails Applicationsの修正です。

Functional Tests for Your Controllersの項の言い回しを修正しています。


Document the include_all_helpers config setting.

rails guideのConfiguring Rails Applicationsの修正です。

config.action_controller.include_all_helpersについての説明を追加しています。


Compare http request type with test equivalent methods, and application use-cases.

HTTPメソッドについて説明している箇所を修正しています。


Rephrase Four Hashes of the Apocalypse [ci skip]

rails guideのA Guide to Testing Rails Applicationsの修正です。

The Four Hashes of the Apocalypseの項の言い回しを修正しています。


These are technically objects [ci skip]

rails guideのA Guide to Testing Rails Applicationsの修正です。

@request@responseについて説明している箇所に、それぞれオブジェクトである旨説明を追加しています。


Pass through Testing Templates and Layouts section [ci skip]

rails guideのA Guide to Testing Rails Applicationsの修正です。

Testing Templates and Layouts項全体のグラマー、言い回し等の修正を行っています。


Implement testing flash notices into our blog app [ci skip]

rails guideのA Guide to Testing Rails Applicationsの修正です。

flashのテストのやり方についての説明を追加しています。


Add doc for :touch option of AR::Base#save

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

ActiveRecord:::Base#saveメソッドの、touchオプションについての説明を追加しています。


Pass through assert_select testing guide [ci skip]

rails guideのA Guide to Testing Rails Applicationsの修正です。

assert_selectメソッドについて説明している箇所全体のグラマー、言い回し等の修正を行っています。


Update link to rails-dom-testing documentation [ci skip]

rails guideのA Guide to Testing Rails Applicationsの修正です。

rails-dom-testingのdocのリンクをgithubからrubydocに修正しています。


Remove pre-4.2 comment about missing assert_select [ci skip]

rails guideのA Guide to Testing Rails Applicationsの修正です。

不要なassert_selectについてのNOTEを削除しています。


fix error message of option as with invalid charters in partial rendering

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

renderメソッドasオプションに不正な値を指定した場合に、適切なエラーメッセージを表示するよう修正しています。

@view.render(:partial => "test/a-in", :as => 'a-in')
# => "The value (a-in) of the option `as` is not a valid Ruby identifier; make sure it starts with lowercase letter, and is followed by any combination of letters, numbers and underscores."

Grammar pass through Integration Testing section [ci skip]

rails guideのA Guide to Testing Rails Applicationsの修正です。

Integration Testingセクション全体のグラマーの修正を行っています。


Move longer form example from integration guide to api reference, below an

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

Testing guideに記載されていたIntegration TestのexampleをIntegrationTestクラスのdocに移動しています。


Remove redundant information about Minitest, which is already covered when

rails guideのA Guide to Testing Rails Applicationsの修正です。

A Brief Note About Minitestの項を削除しています。 そこまでのguideの説明で、既に同じ内容を記載している為との事。


Condense notes regarding Minitest and its available assertions removed in:

rails guideのA Guide to Testing Rails Applicationsの修正です。

Minitestについての説明を追加、及びMinitestのassertionメソッドを一通り記載していたのを削除しています。assertionメソッドについては、API docの方を見てとの事。


Fix form_for to work with objects that implement to_model

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

form_forメソッドの引数にto_modelメソッドを適切に実装したオブジェクトを指定した場合、4.1では正常に動作していたのが、4.2で動作しなくなってしまっていたのを、再度動作するよう修正しています。


Move Rake tasks list to a smaller heading section earlier in the guide.

rails guideのA Guide to Testing Rails Applicationsの修正です。

Rake Tasks for Running your Testsの項をguide内のより適切な位置に移動しています。


Template lookup now respect default locale and I18n fallbacks.

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

mailerのtemplateを検索する際、デフォルトのロケールを参照するよう修正しています。

mailer/demo.html.erb
mailer/demo.en.html.erb
mailer/demo.pt.html.erb

上記テンプレートがあった場合、デフォルトロケールに"en"が設定されていてもdemo.html.erbレンダリングされていたのが、 最初にdemo.en.html.rbレンダリングするよう修正しています。レイアウトファイルも同様です。


AR specific length validator to respect marked_for_destruction.

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

validates_size_of / validates_length_of がレコードのカウントではなく、marked_for_destruction?の数をカウントするよう修正しています。

オブジェクトの削除を行った際、レコードでカウントしていると削除予定のレコードもカウントされてしまい、期待通りのvalidateが設定されないので、 marked_for_destructionの方をカウントするようにしたとの事です。

このバグ、最初に起票されたのが2009年5月だったので、五年越しでの対応との事です