なるようになるブログ

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

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

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

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

actionview/CHANGELOG.md


Add tests to make sure mail_to work with nil and SafeBuffer

actionview/test/template/url_helper_test.rbの修正です。

mail_toメソッドSafeBuffer、またはnilを指定した場合のテストを追加しています。

4系(4.1、4.2両方)で上記を指定した場合に正しく動作しなかった(masterは問題無かった)為、リグレッション防止の為に、テストだけ追加されているようです。


Update docs/comments to use setup/teardown blocks vs. methods.

activesupport/lib/active_support/log_subscriber/test_helper.rbguides/source/active_model_basics.mdguides/source/testing.mdの修正です。

テストの前処理/後処理でsetup/teardownメソッドを使用していたのを、setup/teardown blockを使用するよう修正しています。

 class ArticlesControllerTest < ActionController::TestCase
   # called before every single test
-  def setup
+  setup do
     @article = articles(:one)
   end

   # called after every single test
-  def teardown
+  teardown do
     # when controller is using cache it may be a good idea to reset it afterwards
     Rails.cache.clear
   end

元々、railsとしてはblockの方を使うよう推奨していたのと、メソッドの方を使った場合に、minitest-spec-railsで問題があった(before/setup inconsistency · Issue #68 · metaskills/minitest-spec-rails)ようで、blockの方を使用するよう統一しています。


Fix deprecation message when frame doesn't have absolute_path

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

ActiveSupport::Deprecation.extract_callstackメソッドで、問題が発生した行を特定する際に、frameがnilの場合の考慮を追加しています。

           rails_gem_root = File.expand_path("../../../../..", __FILE__) + "/"
           offending_line = callstack.find { |frame|
-            !frame.absolute_path.start_with?(rails_gem_root)
+            frame.absolute_path && !frame.absolute_path.start_with?(rails_gem_root)
           } || callstack.first
           [offending_line.path, offending_line.lineno, offending_line.label]

Don’t allow arbitrary data in back urls

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

link_toメソッド:backオプションを指定した場合、HTTP_REFERERヘッダーが設定されていたらその値、ヘッダーが無ければjavascript:history.back()を返すようになっていましした。

ただ、HTTP_REFERERヘッダーの値を返す際、値のチェックは行っていなかったので、仮にjavascript:alert("!")のようなJSが設定されていた場合に、それがそのまま実行されてしまっていました。

これを、HTTP_REFERERの値をチェックして、javascriptスキームの場合はその値は使用しないよう修正しています。


don't start a new process for every test file

railties/Rakefileの修正です。

テストをパラレルに実行する際、テストファイル毎にプロセスを生成していたのを、一度作ったプロセスを使いまわすよう修正しています。


Fix spelling error [ci skip]

activerecord/CHANGELOG.mdの修正です。

deprecateddepreactedにタイポしていたのを修正しています。