なるようになるブログ

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

rails commit log流し読み(2014/08/14)

rails commit log流し読み(2014/08/14)

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

actionpack/CHANGELOG.md

activerecord/CHANGELOG.md

actionview/CHANGELOG.md

Add I18n support for input/textarea placeholder text.


Missing ActiveSupport require for calling String#first

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

require 'active_support/core_ext/string/access'を追加しています。


[ci skip] add note about the ERB escape in generator docs

rails guideのCreating and Customizing Rails Generators & Templatesの修正です。

ERBについての説明を追加しています。


UnexpectedErrors may reference exceptions that can't be dumped

actionpack/test/abstract_unit.rbの修正です。

パラレルでテストを行ってエラーが起きた際に、Marshal.dumpでエラーの内容を出力するのですが、そのdumpでエラーが起きた際に、エラーの情報を元にMinitest::UnexpectedErrorクラスを作成するよう対応しています。


this should be accessing the hash, not calling a method

actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.text.erbの修正です。

traceにアクセスする際、メソッド呼び出しではなくhashの値を使用するよう修正しています。

-<%= trace.map(&:trace).join("\n") %>
+<%= trace.map { |t| t[:trace] }.join("\n") %>

fewer operations on the options hash

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

Mapping.build及びMapping#initializeメソッドas引数を追加しています。

optionsへの参照を減らす為ですかね。


pass consistent parameters to canonical_action?

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

resource_method_scope?メソッドに引数を追加しています。Hashの参照削減のためかと。


only test prefix once

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

2回行われていたprefixのチェックを一度だけ行うよう修正しています。


only look up scope level once

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

prefix_name_for_actionメソッドscope_level引数を追加しています。Hashの参照を減らす為。


Finally! None of our tests are order_dependent!

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

ActiveSupport::TestCase.my_tests_are_order_dependent!を削減しています。

これでmy_tests_are_order_dependent!が全て削除完了のようです。


move scope_level to a method on the scope object

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

Hashのkey(scope_level)を直接参照していたのをメソッドに切り出して、メソッドで確認を行うよう修正しています。


move the scope level key fully inside the scope object

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

こちらも同様。インスタンスを生成する際に、Hashのkeyを直接参照をしていたのをメソッドに切り出しています。


scope_level is no longer a hash key, just use the ivar

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

scope_levelを直接参照している箇所があったのを修正しています。


change to attr_reader

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

scope_levelの呼び出しをメソッドからattr_readerに修正しています。


reduce calls to scope_level

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

scope_level:resoucesの比較処理をメソッドに切り出しています。

-          if @scope.scope_level == :resources
+          if @scope.resources?
+        def resources?
+          scope_level == :resources
+        end

ハードコーディングされているのSymbolを減らす為ですかね。


ask the scope for the action name

actionpack/lib/action_dispatch/routing/mapper.rb

name_for_actionメソッドで行っていたアクション名の取得処理をaction_nameに切り出しています。


ask the scope object if it is a resource_method_scope

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

scope確認用の処理をresource_method_scope?メソッドに切り出しています。


Merge pull request #16027 from tgxworld/template_assertions

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

assert_templateメソッドの引数にfile: nil又はfile: falseを指定した場合、ファイルのrenderが無い場合にtrueになるよう修正しています。


Clear validators before and after each test

activerecord/test/cases/validations/i18n_validation_test.rbactiverecord/test/cases/validations_repair_helper.rbの修正です。

setuprepair_validationsメソッドを呼び出すよう修正しています。

テストがランダムで実施されるようになった影響で、エラーになってしまったのを対応しています。

因みに、コメントでteardownでやった方が良くない? という質問が投げられているので、再度修正があるかも。


remove deprecated MissingHelperError proxy.

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

deprecatedだったAbstractController::Helpers::ClassMethods::MissingHelperErrorを削除しています。


ಠ_ಠ now that the commit sha is known I can add it to the relese guide.

guides/source/4_2_release_notes.mdの修正です。

上記対応について、4_2_release_notesに対象コミットのリンクを追加しています。


Format

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

クラス名の後ろにスペースを追加しています。


Make sure that fixtures are loaded before finding

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

setupにfixtureの読み込み処理を追加しています。


Merge pull request #8813 from greyblake/dont_write_timestamps_if_they_are_not_attributes

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

timestampsのカラムが無い時、timestampsデータの書き込み処理を行わないよう修正しています。

カラムチェックに誤りがあったらしく、WARNINGが出てしまっていたようです。

因みに、PRが作られたのは"8 Jan 2013"となっているので、また大分古いPRですねえ。


Ignore SCHEMA queries in some habtm tests

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

幾つかのテストでassert_no_queriesメソッドignore_none: falseを追加しています。


Fixed AR::Relation#where edge case with Hash and other Relation

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

ActiveRecord::Relation#whereメソッドHashまたは他のRelationを使用した場合に、動作しなくなっていたのを対応しています。

Author.where(posts: { author_id: Author.where(country_id: 1) }).joins(:posts)

因みに、 ネストは1階層までのみの対応のようです。確かに、そんなに深くまで対応する必要な無さそうですよねえ。


Merge pull request #16438 from agrobbin/input-placeholder-i18n

actionview/lib/action_view/helpers/tags/placeholderable.rbの修正です。

input/textareaタグのplaceholderにi18nサポートを追加しています。

以下テストコードから一部抜粋。

helpers: {
  placeholder: {
    post: {
      title: "What is this about?",
      written_on: {
        spanish: "Escrito en"
      },
      comments: {
        body: "Write body here"
      }
    },
    tag: {
      value: "Tag"
    }
  }
}
text_field(:post, :body, placeholder: true)
# => <input id="post_body" name="post[body]" placeholder="Body" type="text" value="Back to the hill and over it again!" />

whole_form("/posts/123", "create-post", "edit_post", method: "patch")
# => <input id="post_comments_attributes_0_body" name="post[comments_attributes][0][body]" placeholder="Write body here" type="text" />

localeファイルのhelpers.placeholder配下に値を追加すればOKなようです。便利そう。