【发布时间】:2016-08-01 17:56:46
【问题描述】:
我正在尝试为仅对登录用户可见的 URL 编写一个简单的测试(我使用 before_action :authenticate_user! 来实现此目的)。
尽管我(认为)我正确分配了所有标头,但我总是得到 JSON 响应 {"errors":["Authorized users only."]}
我的测试看起来像这样(登录(获取标头信息)然后访问受保护的 URL 以及所需的所有标头)
post "/api/v1/auth/sign_in", {:email => user.email, password: 'password'}
header_hash = {
'access-token' => response.headers['access-token'],
'uid' => response.headers['uid'],
'client' => response.headers['client'],
'expiry' => response.headers['expiry']
}
get "/api/v1/subscription_status", nil , header_hash
我做错了什么?
【问题讨论】:
标签: ruby-on-rails authentication devise token