なるようになるブログ

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

rails commit log流し読み(2014/05/04)

2014/05/04分のコミットです。

細かい修正だけで、機能追加/変更のような大きなコミットはありませんでした。


docs, restructure newly added part to includes. [ci skip]

ActiveRecord::Associasionsのdocの修正です。説明の順番を少し入れ替えています。


Refactor test to not care about the specific result of valid?

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

結果がtrue/falseになるテストで、assert_equalメソッドを使っていたのを、assert/assert_notメソッドにそれぞれ変更しています。


Remove duplicated fixture addition

activerecord/test/cases/associations/has_many_associations_test.rbの修正です。同じfixture名が2回指定されてしまっているのを修正しています。


Reorganize ActiveRecord tasks [Arun Agrawal & Abd ar-Rahman Hamidi]

ActiveRecordの一部タスクの再編成です。

# examples

  # before
  mysql:build_databases
  mysql:drop_databases
  mysql:rebuild_databases
  test_mysql2

  # after
  mysql:db:build
  mysql:db:drop
  mysql:db:rebuild
  test:db:mysql2

namespaceにdbが追加された形ですね。


Revert "Merge pull request #14940 from arunagw/hbakhtiyor-test-db-namespaces-ar"

と、コミットされた上記namespaceの変更ですが、直ぐ様revertされています。

bundle exec rake test:db:postgresqlsqlite3のアダプターが使用されてしまっている為、との事です。


Remove tests method for test cases when controller can be inferred.

controller系のテストコードの修正です。コードから不要なtestsメソッドを削除してます。

testsメソッドはtest_case.rbで定義されており、test対象のcontrollerを指定する為のメソッドです。

テストクラス名とテスト対象のcontrollerが一致する場合、testsメソッドが不要なので、削除しているですね。


Merge pull request #14959 from akshay-vishnoi/doc_changes

actionview/lib/action_view/lookup_context.rbのdocの修正です。typo及び文法の修正です。


refactor, move column_for to AbstractAdapter for better reuse.

ActiveRecord::ConnectionAdapters::AbstractAdapter::AbstractMysqlAdapter、に定義されていたcolumn_forメソッドをAbstractAdapterに移動しています。

他のDBのadapterでも似たよな処理を行っていたので、処理の共通化の為ですね。


Document ActionController::TestCase::Behavior#process

ActionController::TestCase::Behavior#processのdocを追加しています。

HTTP requestをシミュレートするためのメソッドのようです。

# example: calling +create+ action & sending two params
#
#  process :create, 'POST', user: { name: 'Gaurish Sharma', email: 'user@example.com' }

これ便利そうな。


Rails One Click is not maintained anymore [ci skip]

rails guideのGetting Startedの修正です。

メンテナンスされていないRails One Clickを削除し、代わりにTokaidoを追加しています。


Convert column name to string only once

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

ブロックの中で複数回行われてしまっていたto_sメソッドを、外だしして一度だけ処理するよう修正しています。


Simplify unless conditional with OR

こちらもactiverecord/lib/active_record/connection_adapters/abstract_adapter.rbの修正です。

不要なunlessを削除しています。


Get rid of conditional since column_for handles raising now

ActiveRecord::ConnectionAdapters::Column#rename_column_sqlメソッドの修正です。

指定されたcolumnが存在しない場合にActiveRecordErrorをraiseするようになっていたのですが、column_forメソッドの中でraiseされるので、ここでraiseする必要な無いので、raise処理を削除しています。


Simplify building options hash in rename column method for mysql

ActiveRecord::ConnectionAdapters::Column#rename_column_sqlメソッドの修正です。

Hashの作成処理を以下のように修正しています。

# befor
  options = { name: new_column_name }
  options[:default] = column.default
  options[:null] = column.null
  options[:auto_increment] = column.extra == "auto_increment"

# after
  options = {
    name: new_column_name,
    default: column.default,
    null: column.null,
    auto_increment: column.extra == "auto_increment"
  }

Use the reader attribute rather than the instance var when possible

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

インスタンス変数を参照している箇所を、アクセサメソッドを使用する修正しています。

これ何ででしょう。アクセサメソッドの方が効率良いとか、あったかな。


Fix examples indent and improve #process docs a bit [ci skip]

ActionController::TestCase::Behavior#processのdocのインデント及び改行等を修正しています。