なるようになるブログ

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

rails commit log流し読み(2015/07/09)

2015/07/09分のコミットです。

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


allocate new responses rather than recycling them

actionpack/lib/action_controller/test_case.rbの修正です。

テストでresponseオブジェクトを生成するのに、独自に定義したrecycle!メソッドを経由してオブジェクトを生成していたのを、普通にnewメソッド経由でオブジェクトを生成するように修正しています。


remove useless new implementation

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

先のコミットにより不要になったTestRequest.newメソッドを削除しています。


Add method call assertions for internal use.

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

指定したメソッドが呼ばれた/呼ばれないことを確認する為のテスト用のassertionとして、assert_calledassert_not_calledメソッドを追加しています。

mock = Minitest::Mock.new
mock.expect(:call, nil, [])
original.stub(:delete, mock) do
  original.except(:a)
end

assert_equal "expected call() => nil, got []", assert_raises(MockExpectationError) { mock.verify }.message

上記のような処理をメソッドにまとめた感じになります。Railsが内部で使うようで、通常ユーザが使うようではないようです。


let the superclass build the request and response

ActionPackの修正です。

テスト毎にrequest/responseオブジェクトを生成していたのを、親クラスの前処理で作成して、それを使いまわすよう修正しています。


Add Deserialization section on guides at ActiveJob Exception

rails guideのActive Job Basicsの修正です。

Deserializationの項を追加して、ジョブ実行前にジョブに渡されたrecordが削除された場合に、ActiveJob::DeserializationErrorが発生する旨説明を追加しています。


pass the session and env in to the test request

actionpack/lib/action_controller/test_case.rbの修正です。

TestCase#build_requestメソッドでテスト用のリクエストを作成する際、セッション情報も渡すよう修正しています。


remove call to build_request

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

不要なbuild_requestメソッドの呼び出しを削除しています。


pass the starting env and session to build_request

actionpack/lib/action_controller/test_case.rbの修正です。

TestCase#build_requestメソッドの引数にenv、sessionを追加しています。


make env a required parameter

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

TestRequestクラスのコンストラクタで、 任意の引数だったenvを必須引数に修正しています。


add a new constructor for allocating test requests

actionpack/lib/action_controller/test_case.rbの修正です。

TestCaseクラスに、オブジェクト生成用の新規メソッド(createメソッド)を追加しています。


pass the variant as a parameter to more reflect real world apps

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

variantsのテストで、@requestオブジェクトの値を操作してvariantを設定していたのを、getメソッドのパラメータに指定するよう修正しています。実際使われる場合は、当然パラメータとして送信されてくる情報なので、より実際のケースに近い形でテストした方が良いだろう、という事で修正したようです。


request objects are no longer recycled

actionpack/lib/action_controller/test_case.rbの修正です。

TestResponse#processメソッド実行時、もともと保持していたrequest オブジェクトを再利用するのではなく、必要な情報のみ引き継いで、随時オブジェクトを再作成するよう修正しています。


assign the cookie hash on request allocation

actionpack/lib/action_controller/test_case.rbの修正です。

request オブジェクト生成時に、cookie hashを設定するよう修正しています。


use new constructor. (Oops! :bomb:)

actionview/lib/action_view/test_case.rbactionview/test/actionpack/controller/view_paths_test.rbの修正です。

TestRequestクラスのオブジェクトを生成するのに、新規に追加したcreateメソッドを使用するよう修正しています。


build and assign parameters rather than rely on mutations

actionpack/lib/action_controller/test_case.rbactionpack/test/controller/test_case_test.rbの修正です。

action_dispatch.request.query_parametersaction_dispatch.request.request_parametersをrequestオブジェクトにメソッド経由で設定出来るよう対応しています。


Allow pluralize helper to take a locale.

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

pluralizeメソッドにlocaleを渡せるよう対応しています。

pluralize(2, 'Person', locale: :de) # => 2 Personen

use JSON to communicate between the controller and the tests

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

controllerとテストのデータ連携にJSONを使用するよう修正しています。