2015-10-11 04:41:23 -05:00
|
|
|
require 'rails_helper'
|
2013-02-24 04:42:04 -06:00
|
|
|
require_dependency 'current_user'
|
|
|
|
|
|
|
|
describe CurrentUser do
|
2013-02-25 10:42:20 -06:00
|
|
|
it "allows us to lookup a user from our environment" do
|
2017-01-31 16:21:37 -06:00
|
|
|
user = Fabricate(:user, active: true)
|
|
|
|
token = UserAuthToken.generate!(user_id: user.id)
|
2013-02-24 04:42:04 -06:00
|
|
|
|
2017-01-31 16:21:37 -06:00
|
|
|
env = Rack::MockRequest.env_for("/test", "HTTP_COOKIE" => "_t=#{token.unhashed_auth_token};")
|
2015-01-09 10:34:37 -06:00
|
|
|
expect(CurrentUser.lookup_from_env(env)).to eq(user)
|
2014-05-22 17:13:25 -05:00
|
|
|
end
|
2014-05-22 13:55:36 -05:00
|
|
|
|
2013-02-24 04:42:04 -06:00
|
|
|
end
|