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
jmt
13,877 PointsCreating the Friendship - test failure
In the "Creating the Friendship" video around 7:11, I'm getting the same test failure after I add the new code.
Test failure:
1) Failure:
test: #create when logged in with a valid friend_id should assign a friend objec
t. (UserFriendshipsControllerTest) [test/functional/user_friendships_controller_
test.rb:93]:
Failed assertion, no message given.
13 tests, 16 assertions, 1 failures, 0 errors, 0 skips
Code:
def create
if params[:friend_id]
@friend = User.where(profile_name: params[:friend_id]).first
else
flash[:error] = "Friend Required"
redirect_to root_path
end
end
end
should "assign a friend object" do
assert assigns(:friend)
end
3 Answers
Jason Seifer
Treehouse Guest TeacherHey john tabor can you post a link to your code on GitHub so I can take a look?
jmt
13,877 PointsHi Jason Seifer , my apologies, I ended up figuring it out. I had a .id in this code after (:mike) I removed the .id and it works fine. Thanks!
context "with a valid friend_id" do
setup do
post :create, friend_id: users(:mike)
end
Jason Seifer
Treehouse Guest TeacherAwesome work John!