Complete the code to send a GET request to the index action in a Rails controller test.
get [1]In Rails controller tests, to test the index action, you send a GET request to users_url.
Complete the code to check that the response was successful in a Rails controller test.
assert_response [1]The assert_response :success checks that the HTTP response status is 200 OK.
Fix the error in the test code to correctly check that a new record was created after a POST request.
assert_difference('[1].count', 1) do post users_url, params: { user: { name: 'Alice' } } end
The model class name User must be capitalized to check the count of records.
Fill both blanks to test that the show action renders successfully for a given user.
get [1]([2]) assert_response :success
Use user_url to send the GET request and user to specify the user.
Fill all three blanks to test updating a user's name and checking the redirect.
patch [1], params: { id: [2].id, user: { name: 'Bob' } } assert_redirected_to [3]
Use user_url(user) for the patch request URL, pass the user object for the id, and check redirect to user_url(user).