blob: 47a601ce074761a5a90e3c90ef29494cfc34bbd0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
module Authentication
def http_login(user)
new_session = UserSession.new
allow(controller).to receive(:user_session).and_return(new_session)
allow(controller).to receive(:current_user).and_return(user)
allow(controller).to receive(:current_user?).and_return(true)
end
def api_login(user)
encoded_credentials = ActionController::HttpAuthentication::Token.
encode_credentials(user.authentication_token)
request.env["HTTP_AUTHORIZATION"] = encoded_credentials
end
module Capybara
def http_login(user)
LoginPage.new.visit_page.login_with(email: user.email, password: "password")
end
end
end
|