なるようになるブログ

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

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

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

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

activerecord/CHANGELOG.md

actionmailer/CHANGELOG.md

railties/CHANGELOG.md


gem 'mysql2', '~> 0.3.18'

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

mysql2 gemのバージョン指定を0.3.13 -> 0.3.18に修正しています。

Gemfileへの指定自体はFormat the time string according to the precision of the time columnで対応済みだったのですが、テスト内でバージョン指定している箇所があり、そちらの修正が漏れていたので追加で修正したようです。


add note about habtm relations with scopes

rails guideのA Guide for Upgrading Ruby on Railsの修正です。

has_and_belongs_to_manyjoin_tableオプションを指定した場合のネームスペースの解釈が3.2 -> 4.0の際に変更になり、変更になった旨注記を追加しています。


Move the collation handling code from the MySQL adapter to common classes

ActiveRecordの修正です。

MySQL adapterの中に記載されていたcollationオプションに関する処理を、adaper 共通クラスの中に移動しています。


PostgreSQL: :collation support for string and text columns

ActiveRecordの修正です。

PostgreSQLtextstring型のカラムにcollationオプションを指定出来るよう対応しています。

create_table :foos do |t|
  t.string :string_en, collation: 'en_US.UTF-8'
  t.text   :text_ja,   collation: 'ja_JP.UTF-8'
end

Missing :bigint [ci skip]

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

対応している型の一覧にbigintが漏れていたので、追加しています。


Merge pull request #19498 from chanks/activejob-que-remove-named-queues

activejob/lib/active_job/queue_adapters/que_adapter.rbactivejob/test/support/que/inline.rbの修正です。

Que Adapterでqueuequeue_nameを指定するのを止めています。

     class QueAdapter
       def enqueue(job) #:nodoc:
-        JobWrapper.enqueue job.serialize, queue: job.queue_name
+        JobWrapper.enqueue job.serialize
       end

Queのnamed queuesは複数のアプリがひとつのDBを使用する際のようなレアケースの為に作られた機能で、通常使用する必要は無い、かつ、 Que 1.0の際に機能を削除する予定がある、との事で修正したようです。

詳細はPR参照。


Disable warnings on activejob tests

activejob/Rakefileの修正です。

ActiveJobのテストでwarningが出力されないよう変更しています。

ActiveJobは依存しているライブラリが多く、そのライブラリ達が大量にwarningを出力してしまい、出力を読むのが困難、という事で無効にしたようです。


Do not use named queues for que adapter

activejob/test/integration/queuing_test.rbactivejob/test/support/integration/adapters/que.rbの修正です。

Que adapterのテストでnamed queuesを使用しないよう修正しています。


Merge pull request #17824 from yuki24/change-record-not-saved-and-not-destroyed-to-include-error-msg

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

ActiveRecord::RecordNotSavedActiveRecord::RecordNotDestroyedでエラーになった際、適切なエラーメッセージが表示されるよう修正しています。


Merge pull request #18783 from mikestone14/actionview-image-tag-override

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

image_tagメソッド:sizeオプションと:widthオプション又は:heightオプションを同時に指定した場合に、ArgumentErrorをraiseするよう修正しています。


Merge pull request #19994 from kamipo/dump_indexes_in_create_table

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

dumpする際、indexの情報をadd_indexではなく、TableDefinition#indexとして出力するよう修正しています。

例。

# before
create_table "users", force: :cascade do |t|
  t.bit      "settings",      limit: 8
  t.datetime "created_at",              null: false
  t.datetime "updated_at",              null: false
  t.string   "name"
end

add_index "users", ["name"], name: "index_users_on_name", using: :btree

# after
create_table "users", force: :cascade do |t|
  t.bit      "settings",      limit: 8
  t.datetime "created_at",              null: false
  t.datetime "updated_at",              null: false
  t.string   "name"
  t.integer  "address_count"
  t.index ["name"], name: "index_users_on_name", using: :btree
end

Merge pull request #19976 from prathamesh-sonpatki/rm-assigns

railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rbの修正です。

assignsメソッドを使用してたテストをテンプレートファイルから削除しています。

assignsメソッドをdeprecateにする予定がある為削除したようです。詳細はこちら


Merge pull request #19093 from remomueller/fix-actionmailer-preview-links-on-subdirectories

railties/lib/rails/templates/rails/mailers/index.html.erbrailties/lib/rails/templates/rails/mailers/mailer.html.erbの修正です。

mailer previewのURLを生成するのに、url_forメソッドを使用するよう修正しています。

-<h3><%= link_to preview.preview_name.titleize, "/rails/mailers/#{preview.preview_name}" %></h3>
+<h3><%= link_to preview.preview_name.titleize, url_for(controller: "rails/mailers", action: "preview", path: preview.preview_name) %></h3>

アプリをサブディレクトリ配下で動作させていた場合正常にURLの取得が出来ていなかったので修正したとの事です。


Do not use options that does not support

activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rbの取得です。

add_indexindex_in_createメソッドINDEX文を生成する際、MySQLがサポートしていないpartial index用のオプションを渡していたのを、渡さないよう修正しています。


More exercise the create index sql tests

ActiveRecordの修正です。

TableDefinition#indexメソッドについてのテストを追加しています。


Remove unused private classes

railties/lib/rails/test_unit/sub_test_task.rbを削除しています。

Rails::TestRunnerが追加され、rake testが使われなくなったので、それに伴い不要になったTestTaskクラスを削除しています。


Remove unneeded base file

railties/test/application/configuration/base_test.rbrailties/test/application/configuration/custom_test.rbの修正です。

custom configurationのテスト用にBaseTestCustomTestの二つのクラスを使用していたのですが、処理をCustomTestクラスにまとめて、BaseTestクラスの方は削除しています。


Fix generator tests

railties/test/generators_test.rbの修正です。

test_generator_multiple_suggestionsメソッドの期待する結果が環境により異なる事がある? らしく、値を修正しています。

"In my machine the output is different" って事がありえるんですかねえ。


Merge pull request #18561 from nerdcave/serialization-methods-option

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

ActiveModel::Serialization#serializable_hashメソッドmethodsオプションに指定したメソッドが存在しなかった際に、method_missingが呼ばれるよう修正しています。

元々はメソッドを呼び出す前にrespond_to?メソッドの存在チェックをしていた為、メソッドが見つからなかった場合なにも処理が行われていませんでした。


Give authentication methods the ability to customize response message.

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

authenticate_or_request_with_http_basicrequest_http_basic_authenticationメソッドmessageオプションを追加し、レスポンスに任意のメッセージを設定出来るよう対応しています。


Fix mailer previews with attachments

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

mailer previewsで添付ファイル付きのメールを表示しようとするとNoMethodErrorで落ちてしまうバグがあったのを修正しています。

2014/03からずっとあったバグがついに。


Improve display of attachment names in mailer previews

railties/lib/rails/templates/rails/mailers/email.html.erbの修正です。

添付ファイル名を表示する際、Arrayをそのまま表示するのではなく、カンマ区切りでファイル名を表示するよう修正しています。


Add support for inline images to mailer previews

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

mailer previewでメールに埋め込まれた画像も正しく表示されるよう対応しています。


Fix railties configuration test

railties/test/application/configuration_test.rbの修正です。

上記メール埋め込み画像の対応はpreview_interceptorsに表示用のクラス(InlineAttachments)を追加し対応しているのですが、その影響で既存のpreview_interceptorsについてのテストがコケてしまったので、修正しています。


refactor ActiveSupport::TestCase.test_order method with memoization

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

test_orderメソッドActiveSupport.test_orderの値をメモ化するようリファクタリングしています。


Adds/Corrects use case for adding an error message

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

Errors#generate_messageメソッドmessageオプションが指定されている場合、エラーの内容に関わらず、messageオプションに指定されたメッセージを出力するよう修正しています。


Tiny documentation edits [ci skip]

メソッドのdocの修正です。

タイポの修正、1行80文字に収まるよう修正、<tt>の代わりに+を使うよ修正、を行っています。


Updates various prose to the i18n guide

rails guideのRails Internationalization (I18n) APIの修正です。

ガイド全体のグラマーの修正を行っています。


Enhance the "Passing Variables to Translations" part

rails guideのRails Internationalization (I18n) APIの修正です。

Passing Variables to Translationsの項に、実際のサンプルの追加、及びInterpolationの項の内容とマージを行っています。


Silence ambiguous first argument warning

actionpack/test/journey/route_test.rbの修正です。

test_path_requirements_override_defaultsテストで、メソッドの引数の括弧が無くてワーニング(warning: ambiguous first argument)が出力されていたのを修正しています。


Merge pull request #20010 from sikachu/silence-ambiguous-first-argument