Created
December 7, 2009 19:26
-
-
Save devpuppy/251030 to your computer and use it in GitHub Desktop.
[deprecated] hackish way to use Test::Unit with Devise
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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