有人可以解释下面的方法/函数,并解释它是否位于test / test_helper.rb中,其他非测试类/控制器如何访问它?
# Logs in a test user.
def log_in_as(user, options = {})
password = options[:password] || 'password'
remember_me = options[:remember_me] || '1'
if integration_test?
post login_path, session: { email: user.email,
password: password,
remember_me: remember_me }
else
session[:user_id] = user.id
end
end