なるようになるブログ

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

rails commit log流し読み(2014/09/09)

2014/09/09分のコミットです。

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

activerecord/CHANGELOG.md


Do not memoize document_root_element in view tests

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

クラス変数に格納していたhtml documentの情報を変数に保持しないよう修正しています。

最初にassert_select呼び出した後にviewが変更した場合に、正しく値が取得出来ない問題が発生した為修正したようです。コミットログ見る限り、rails-dom-testingの方の問題のような。


Add docs for web-console to 4.2 Upgrade Guide [ci skip]

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

web-consoleについての説明を追加しています。

基本的にはweb-consoleのdocに書いてある内容を追加している感じです。application.rbconfig.web_console.automount = trueを設定する、という説明になっているんですが、developmentでしか使わないgemなので、application.rbに定義するのは不味い気がしますねえ。


Remove extra 'has been' from the deprecation message

actionpack/lib/action_dispatch/testing/assertions/tag.rbの修正です。

TagAssertionsに関するdeprecateメッセージに、"has been"が2回含まれてしまっていたので片方削除しています。


Remove extra 'has been' from deprecation warning about asserting selectors

actionpack/lib/action_dispatch/testing/assertions/selector.rbの修正です。

同上。


Update upgrading guide about error handling in transactional callbacks

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

ActiveRecordのcallbacksでのエラーハンドリングの変更について追記しています。

詳細については、#14488#16537参照。


:scissors: "now" [ci skip]

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

上記修正の追加です。文中から、不要な"now"を削除しています。


Remove extra newline from ActiveJob test template

railties/lib/rails/generators/test_unit/job/templates/unit_test.rb.erbの修正です。

変な所に改行があったので、削除しています。


[ci skip] change the line orientation on asset precompile page

rails guideのThe Asset Pipelineの修正です。

ExecJSの説明の箇所について、改行の位置を調整しています。


Allow included modules to override association methods.

ActiveRecordの修正です。

includeしたmoduleでassociationのメソッドをオーバーライド出来るよう修正しています。

わかりずらかったので、テストから抜粋。

module MyModule
  def comments; :none end
end

class MyArticle < ActiveRecord::Base
  self.table_name = "articles"
  include MyModule
  has_many :comments, inverse_of: false
end

def test_included_module_overwrites_association_methods
  assert_equal :none, MyArticle.new.comments
end

MyArticle.new.commentsは、本来associationのcommentsの筈なのですが、MyModuleをincludeしているので、MyModuleの方のcommentsメソッドが呼ばれている。

挙動的に少し違和感があるのですが、rails 4.0.x系では上記動作で動いていたとの事で、対応しています。


introduce connection.supports_views? and basic view tests.

ActiveRecordのadapterの修正です。

adapterがviewに対応しているかどうかチェックする為の、connection.supports_views?メソッドを追加しています。

現状、テストでだけ使われているようです。チェック処理みて気付いたのですが、MySQL 4系ってview、正式対応してなかったんですね。


add test-cases for primary-key-less-views. Closes #16555.

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

primary keyが無いviewについてのテストを追加しています。


models backed by views don't assume "id" columns are the primary key.

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

idカラムがprimary keyではない場合のテストを追加しています。


Oracle does not support IF EXISTS for DROP VIEW.

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

SQLIF EXISTS xxxを使用していたのを、if @connection.table_exists?を使用するよう修正しています。Oracle対応ですね。