なるようになるブログ

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

rails commit log流し読み(2018/07/15)

2018/07/15分のコミットです。

CHANGELOGへの追加はありませんでした。


Ensure attribute is a symbol in the added? method

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

ActiveModel::Errors#added?で指定されたattributeが追加されているかチェックする前に、値をSymbolに変換するよう修正しています。

added?attributeにStringが指定された場合にも正しくチェック出来るようにする為。


Stub with Minitest instead of Mocha

Active Recordのテストの修正です。

mock処理に、mochaではなくMinitestのMockを使用するよう修正しています。


Fix document issue in active record callback about after_touch hook.

rails guideのActive Record Callbacksの修正です。

after_touchの項にあるexampleで、記載されていた実行結果と実際の内容が異なっていた(callbackの実行順が異なっていた)のを修正しています。


test_should_impose_childless_html_tags_in_html failure with JRuby

actionpack/test/controller/test_case_test.rbの修正です。

test_should_impose_childless_html_tags_in_htmlJRubyとCRubyとでcss selectorの指定をわけています。

+    if defined?(JRUBY_VERSION)
+      # https://github.com/sparklemotion/nokogiri/issues/1653
+      # HTML parser "fixes" "broken" markup in slightly different ways
+      assert_select "root > map > area + p"
+    else
+      assert_select "root > area + p"
+    end

assert対象のHTMLはタグの構成が正しくないHTML(areaタグの親がいない)なのですが、このHTMLをnokogiriでparseした場合の結果が、CRubyとJRubyで異なる結果になる為。

具体的には、<?xml version=\"1.0\" encoding=\"UTF-8\"?><root><area><p>content</p></area></root>というようなHTMLをパースした場合、

# jruby / nekohtml
<html>
  <head></head>
  <body>
    <root><map><area><p>content</p></map></root>
  </body>
</html>
# mri / libxml2
<html>
  <body>
    <root><area><p>content</p></root>
  </body>
</html>

となるとの事です。

参考:Selector inconsistency between MRI and JRuby