Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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!