summaryrefslogtreecommitdiff
path: root/spec/support/http_authentication.rb
blob: f6c5a204d627474590f7f54bf065ee8219050d1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
module HttpAuthentication
  def http_login(user, user_session =
                 build(:user_session, id: SecureRandom.uuid, user: user))
    allow(controller).to receive(:current_user).and_return(user)
    allow(controller).to receive(:current_session).and_return(user_session)
    session[:user_id] = user_session.id
  end

  def api_login(user)
    http_login(user)
  end
end