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

Brandon Barrette
Brandon Barrette
20,485 Points

Bocking UI erros in user_friendship_controller_test

I'm getting errors only on the "accepted_user_friendship" portion of the tests. Here's the errors I am getting:

1) Error:
test: #index when logged in accepted friendships should display requested friends.     (UserFriendshipsControllerTest):
NoMethodError: undefined method `accepted_user_friendships' for #    <User:0x0000010527b8d8>

There seems to be an undefined method somewhere, but I can't figure out how to fix this. I've looked at the files from the download zip on this section and can't seem to find what's wrong. Any pointing in the right direction would be much appreciated.

Here's the part of the test that is failing:

context "accepted friendships" do
            setup do
                get :index, list: 'accepted'
            end

            should "get the index without error" do
              assert_response :success
            end

            should "not display pending or active friend's names" do
              assert_no_match /Blocked/, response.body
              assert_no_match /Requested/, response.body
            end

            should "display requested friends" do
              assert_match /Active/, response.body
            end
        end
Brandon Barrette
Brandon Barrette
20,485 Points

So I got this fixed, but now I'm getting failures on the tests (which is better than errors I keep telling myself).

Here is one error with the appropriate test that is failing:

1) Failure:
test: #index when logged in accepted friendships should not display blocked or requested friend's     names. (UserFriendshipsControllerTest) [test/functional/user_friendships_controller_test.rb:77]:
</Blocked/> expected to not match

should "not display blocked or requested friend's names" do
              assert_no_match /Blocked/, response.body
              assert_no_match /Requested/, response.body
            end

I guess I may be not understanding how the "blocked" friends are being labeled. To me, what this sounds like is that it is searching the page for "Blocked". But of course we will see "Blocked" because we've put a "link_to" tag to show all "blocked" members in the list. Should this actually read "Blocked Friends" like we did for pending?

Any thoughts would be great! Thanks!

Brandon Barrette
Brandon Barrette
20,485 Points

Thanks @Jason Seifer. I actually fixed this by looking at your code. You did some updates between "Building Social Features" the second set of videos and "Advanced Social Features" the third set.

I was able to modify my test code to match the modifications made in the views.

Thanks for all your help!

1 Answer

Answer is in the replies.

Way to go Jason and Brandon!