なるようになるブログ

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

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

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

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

activerecord/CHANGELOG.md


Added SchemaDumper support for tables with jsonb columns.

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

SchemaDumperPostgreSQLのJSONB型の対応を追加しています。

JSONB自体のサポートはこのコミットで追加済みだったのですが、SchemaDumperのケアが漏れていたようです。


Mention that articles resource should be added by user in getting started guide

rails guideのGetting Started with Railsの修正です。

Getting Up and Runningの項で、config/routes.rbへの処理の追加についての説明を修正しています。


activerecord: rake db:create shows underlying error message.

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

rake db:createに失敗した際に、エラーの詳細を表示するよう修正しています。

$ RAILS_ENV=test bin/rake db:create
#<Mysql2::Error: Can't connect to MySQL server on '172.17.0.61' (113)>
Couldn't create database for {"encoding"=>"utf8mb4", "collation"=>"utf8mb4_general_ci", "pool"=>5, "adapter"=>"mysql2", "username"=>"root", "password"=>"root", "port"=>3306, "database"=>"example_test", "host"=>"172.17.0.61"}, {:charset=>"utf8mb4", :collation=>"utf8mb4_general_ci"}
(If you set the charset manually, make sure you have a matching collation)

add a test for #17106

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

Rails 4.2で、Applicationクラス読み込み時に、$LOAD_PATHにlibが含まれていない問題が発生しており、その確認の為のテストを追加しています。


add lib to $LOAD_PATH on application inhertence. fixes #17106

railties/lib/rails/application.rbrailties/lib/rails/engine.rbの修正です。

Applicationクラス読み込み時に、$LOAD_PATHにlibが含まれるよう対応しています。


[ci skip] Fixup spelling and grammar in 4.2 guides

rails guideのRuby on Rails 4.2 Release Notesの修正です。

スペルミスの修正、グラマーの修正等を行っています。


[ci skip] fix config.assets.digest default value

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

Rails 4.2 から、development.rbconfig.assets.digest = trueが設定されるようになったので、その旨説明を修正しています。


Fix broken string_ext_test due to change in timezone

activesupport/test/core_ext/string_ext_test.rbの修正です。

モスクワのタイムゾーンが、最近UTC+4からUTC+3に変更になったらしく、その影響でコケてしまったテストを修正しています。

タイムゾーンについて、詳細はwiki参照。


Removed the unused require of proxy_object and test related to it

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

使用していないactive_support/proxy_objectのrequireを削除しています。


Remove skip-gems from 4-2 release notes

rails guideのRuby on Rails 4.2 Release Notesの修正です。

release noteからskip-gemsオプションについての記述を削除しています。 代わりに、後ほどskip-turbolinksオプションについての説明を追加しています。


Merge pull request #17473 from vipulnsward/rm-unused-method

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

使用していないadd_column_position!メソッドを削除しています。


tests, add note about the usage of a specific timezone. Closes #17448.

activesupport/test/core_ext/string_ext_test.rbの修正です。

test_partial_string_to_timeのテストで、夏時間についてはチェックしてない旨コメントを追加しています。


Add skip-turbolinks entry to 4.2 release notes and improve changelog

rails guideのRuby on Rails 4.2 Release Notesの修正です。

skip-turbolinksオプションについての説明を追加しています。


Update bin/rake about [ci skip]

rails guideのThe Rails Command Lineの修正です。

bin/rake aboutの実行結果を最新の内容に更新しています。


Add test/jobs files in rake stats

railties/lib/rails/code_statistics.rbrailties/lib/rails/tasks/statistics.rakeの修正です。

rake statsにtest/jobs配下のファイルも含むよう修正しています。


Merge pull request #17360 from bronzle/includes_and_unscoped

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

preloading をする際、unscopeの値の受け渡しが漏れていたバグがあったのを修正しています。

PRにあったgistから抜粋。

class Post < ActiveRecord::Base
  has_many :comments, -> { unscope(where: :trashed) }

  default_scope -> { where(trashed: false) }
end

class Comment < ActiveRecord::Base
  belongs_to :post, -> { unscope(where: :trashed) }

  default_scope -> { where(trashed: false) }
end
Post.includes(:comments).first.comments.first
# => SELECT "comments".* FROM "comments"  WHERE "comments"."trashed" = 'f' AND "comments"."post_id" IN (1)

Postクラスのcommentsunscopeメソッドを指定しているので、本来はCommentクラスのdefault_scopeは無視されるべきなのですが、 unscopeの値の受け渡しが漏れていたので、default_scopeがそのまま実行されてしまっていたんですねえ。


Merge pull request #15956 from zuhao/refactor_activesupport_dependencies_test

activesupport/test/dependencies_test.rbリファクタリングです。

前処理後処理の整理、適切なassertionメソッドの使用、等を行っています。