なるようになるブログ

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

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

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

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

activejob/CHANGELOG.md


Merge pull request #19969 from y-yagi/fix_job_helper_method

activejob/lib/active_job/test_helper.rbの修正です。

assert_enqueued_jobsassert_performed_jobsメソッドで、メソッドの引数に指定した期待値と。実際の結果の値が異なる場合に出力されるエラーメッセージ内の、Expectedの値に誤りがあったのを修正しています。

例。

test "sample1" do
  GuestsCleanupJob.perform_later('guest 1')
  assert_enqueued_jobs 2 do
    GuestsCleanupJob.perform_later('guest 2')
  end
end
# before

  1) Failure:
GuestsCleanupJobTest#test_test_1 [/home/yaginuma/program/rails/master/test/jobs/guests_cleanup_job_test.rb:6]:
2 jobs expected, but 1 were enqueued.
Expected: 3
  Actual: 2

# after
  1) Failure:
GuestsCleanupJobTest#test_test_1 [/home/yaginuma/program/rails/master/test/jobs/guests_cleanup_job_test.rb:6]:
2 jobs expected, but 1 were enqueued.
Expected: 2
  Actual: 1

Merge pull request #19844 from stevenspiel/link_to_if_block_helper_addition

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

link_to_ifメソッドの引数に指定したblockを、そのままlink_toメソッドに渡すよう修正しています。

が、link_to_ifメソッドに渡すblockは、conditionがfalseだった場合に実行する処理を指定する為のもので、link_toメソッドに渡す為のモノではないという事で、直後にrevertしています。

<%=
   link_to_if(@current_user.nil?, "Login", { controller: "sessions", action: "new" }) do
     link_to(@current_user.login, { controller: "accounts", action: "show", id: @current_user })
   end
%>

# ユーザがログインしてない場合
# => <a href="/sessions/new/">Login</a>

# ユーザがログイン済みの場合
# => <a href="/accounts/show/3">my_username</a>

なるほどー。


Revert "Merge pull request #19844 from stevenspiel/link_to_if_block_helper_addition"

という訳で、直前のlink_to_ifメソッドの対応をrevertしています。


add test-case for link_to_if behavior with a block.

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

link_to_iflink_to_unlessメソッドの引数にブロックを指定した場合のテストを追加しています。


Update documentation to contain a 24 char token [ci skip]

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

has_secure_tokenメソッドのdocにあるtokenメソッドの実行結果を、実際の実行結果と同じ桁数になるよう修正しています。


Improvement on Activerecord CHANGELOG

activerecord/CHANGELOG.mdの修正です。

シングルクォートで囲まれていたActiveRecord::Type::Numericをバッククォートで囲むよう修正しています。