なるようになるブログ

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

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

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

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

activesupport/CHANGELOG.md

actionview/CHANGELOG.md

activerecord/CHANGELOG.md


Privatize config_accessor as with attr_accessor

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

ActiveSupport::Configurable.config_accessorの可視性がprivateに変更になっています。Rubyattr_accessorと合わせたとの事。


Partial template name does no more have to be a valid Ruby identifier

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

部分テンプレートに使える文字が英数字とアンダースコアだけだったのを、Ruby の識別子であれば使用出来るよう修正しています。_a-in.html.erbとかも使えます。


Merge pull request #18647 from mcls/placeholderable-to-model

ActionViewの修正です。

i18nの値を取得する処理で、Active Modelのインスタンスを取得する際、model_nameメソッドを使用していたのを、to_modelメソッドを使用するよう修正、 及びi18の値取得処理が、異なるメソッドでそれぞれ定義されていたのをHelpers::Tags::Translatorクラスを新規に作成、そちらに処理をまとめるよう対応しています。


placeholder doesn't exist inside this context

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

Translator#callメソッドplaceholderの値が設定されてなければ、I18n.tの値を設定するようになっていたのですが、 メソッドが呼ばれる時点でplaceholderが設定されている事は無いので、値のチェック処理を削除しています(||= -> `='に変更)。


Only check if object respond_to to_model once

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

コンストラクタの引数に指定されたobjectに、to_modelが定義されてるかどうかのチェック処理を、一度だけ行うよう修正しています。


Force generated route to be inserted

railties/lib/rails/generators/actions.rbの修正です。

config/routes.rbにルートを追加する際、同じ内容が定義されているかどうかに関わらず、強制的にルートを値を追加するよう修正しています。

値の追加はThor::Actions#inject_into_fileメソッドで行っているのですが、inject_into_fileメソッドではそんなに厳密に元々の値のチェックを行うわけではないらしく、追加されないよりは、 重複定義でエラーになる方が良いだろう、との事で対応したようです


Add tests to make sure label and placeholder respect to_model

actionview/test/template/form_helper_test.rbの修正です。

placeholderto_modelの値を正しく参照するかどうかのテストを追加しています。


Change the method visibility

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

インスタンス変数のアクセサメソッドの可視性をprivateに変更しています。


Use new hash syntax

actionview/lib/action_view/helpers/tags/translator.rb

1.9以降の新しいHash記法を使用しています。


Use kwags to make the argument meaning explicit

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

initializeメソッドの引数にキーワード引数を使用するよう修正しています。


Rename method to make explicit its intention

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

I18nへの変換処理を行うメソッドの名称をcallからtranslateに変更しています。


Remove special case for symbols at find

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

activerecord-deprecated_finders gemの為に残していたfindメソッドにSymbolを渡した場合の処理を削除しています。 Rails 5ではactiverecord-deprecated_findersはサポートされない為ですね。


Mark some methods as nodoc

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

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


Do not run remove_connection in memory db test

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

DBがsqlite3 のmemory dbの場合に、remove_connectionのテストを実行しないよう修正しています。


Merge pull request #18747 from vipulnsward/merge-skip-callback

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

ActiveSupport::Callback#mergeメソッドmerge_conditional_optionsに名前を変更しています。


Use keyword arguments

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

merge_conditional_optionsメソッドの引数にキーワード引数を使用するよう修正しています。


Merge pull request #18771 from kirs/deprecate-xhr

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

ActionController::TestCaseActionDispatch::Integrationでのxhrメソッドxml_http_requestがdeprecateになりました。 代わりに、getpostメソッドxhrオプションが指定可能になったので、今後はそちらを使うように、との事です。

# before
xhr :get, :create, params: { id: 1 }

# after
get :create, params: { id: 1 }, xhr: true

Merge pull request #18526 from vipulnsward/add-silence-stream

各テストの修正です。

stdout / stderrの値を取得したり、NULLに捨てる為の処理を(silence_stream / quietly / capture)、各コンポーネントのテストクラスでそれぞれ定義していたのですが、 それらをActiveSupport::Testing::Stream moduleにまとめて、各テストクラスではそのmoduleを使用するよう修正しています。


Merge pull request #18589 from kamipo/fix_test_types_line_up

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

test_types_line_upでカラムの一覧にxmlが無かったので追加、及びカラムが無い場合にちゃんとテストが失敗するように、不要なnilデータの削除処理を追加しています。


Merge pull request #18399 from kommen/unify-structure-file-envvar-names

activerecord/lib/active_record/railties/databases.rakeの修正です。

db:structureタスクで、structure fileを指定する際のenvのkeyがDB_STRUCTUREからSCHEMAに変更になりました。

# before
bin/rake db:migrate db:structure:dump DB_STRUCTURE=db/my_structure.sql

# after
bin/rake db:migrate db:structure:dump SCHEMA=db/my_structure.sql

test:load_structureタスクは既にSCHEMAになっていて、それに合わせる形に修正したとの事です。


applies guidelines to dirty.rb [ci skip]

activemodel/lib/active_model/dirty.rbのdocの修正です。

Dirty moduleのrdocから、不要なスペースを削除しています。


use parentheses here, for the beard of the Prophet! [ci skip]

activemodel/lib/active_model/dirty.rbのdocの修正です。

Dirty moduleのexamleでメソッド呼び出しをしている箇所に括弧が無かったので、括弧を追加しています。


revises AM:Dirty example [Godfrey Chan & Xavier Noria]

Dirty moduleのexamleを修正しています。


Merge pull request #18388 from claudiob/better-docs-for-active-model-lint-tests

activemodel/lib/active_model/lint.rbのdocの修正です。

ActiveModel::Lint::Tests moduleのrdocの改善です。全体的にメソッドの説明を直しています。