Skip to content

Instantly share code, notes, and snippets.

@devpuppy
Created December 7, 2009 19:26
Show Gist options
  • Save devpuppy/251030 to your computer and use it in GitHub Desktop.
Save devpuppy/251030 to your computer and use it in GitHub Desktop.
[deprecated] hackish way to use Test::Unit with Devise
# very basic test_helper.rb addition to work with devise
def login_as(user)
if user.is_a?(Symbol)
user = Factory(user)
user.save
end
@request.session[:user] = user
end
def current_user
@request.session[:user]
end
class ApplicationController < ActionController::Base
def logged_in?
!!current_user
# TODO: fix this to work with devise
end
def current_user
session[:user]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment