Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Creating Friendship UI-Testing Controller Responses

I am having problems getting the right answer for Task 2: In the creation test, assert that the response redirects to the profile path for the user fixture of jim.

Here is what I have:

class UserFriendshipsControllerTest < ActionController::TestCase
  context "#create, when not logged in" do

should "redirect to the profile_path" do
  post :create, friend_id: users(:jim).id
  assert_response :redirect
  assert_redirected_to user(:jim)
end

  end
end

I am pretty sure the assert_redirected_to is right but not sure how to redirect it to the profile path for the user fixture of jim.

4 Answers

Figured it out:

      assert_redirected_to profile_path(users(:jim))
Jason Seifer
STAFF
Jason Seifer
Treehouse Guest Teacher

Close! Try changing it to assert_redirected_to profile_path(users(:jim).profile_name))

Thanks for your help Jason!

I have:

class UserFriendshipsControllerTest < ActionController::TestCase
  context "#create, when not logged in" do

  should "redirect to the profile_path" do
    post :create, friend_id: users(:jim).id
    assert_response :redirect
    assert_redirected_to profile_path(users(:jim).profile_name))
  end

 end
 end

But it still says I got it wrong?