rails是控制器中可用的测试中定义的函数

时间:2016-04-23 23:58:25

标签: ruby-on-rails railstutorial.org

有人可以解释下面的方法/函数,并解释它是否位于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

0 个答案:

没有答案