jimchoi (3) [Avatar] Offline
Listing 5.43 introduces the following line to the LocationsControllerTest class, which seems magical to me:

login_as :ludwig

Is "login_as" a function? Where does it come from?

peterarmstrong (94) [Avatar] Offline
Re: Listing 5.43: where does login_as come from?
Yeah, it's a function in AuthenticatedTestHelper, which is mixed in.

module AuthenticatedTestHelper
# Sets the current user in the session from the user fixtures.
def login_as(user)
@request.session[:user] = user ? users(user).id : nil

I probably should have mentioned it. (My decision was to almost completely avoid a discussion of testing, rather than do a bad, incomplete job of it. Testing is a book length topic on its own. However, a bit of an explanation may have helped...)

At this point, it's too late to fix this though...