Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed AuthenticatedTestHelper#login_as, made it accept different type…

…s of arguments.
  • Loading branch information...
commit 3cfb18d5ea99f399e95592bbd02b1762936d6e54 1 parent deed0ce
@igal igal authored
Showing with 16 additions and 1 deletion.
  1. +16 −1 lib/authenticated_test_helper.rb
View
17 lib/authenticated_test_helper.rb
@@ -1,7 +1,22 @@
module AuthenticatedTestHelper
# Sets the current user in the session from the user fixtures.
def login_as(user)
- request.session[:user] = user ? users(user).id : nil
+ identity = \
+ case user
+ when User
+ user.id
+ when String
+ users(user.to_sym).id
+ when Symbol
+ users(user).id
+ when Fixnum
+ user
+ when NilClass
+ nil
+ else
+ raise TypeError, "Can't login as type: #{user.class}"
+ end
+ request.session[:user] = identity
end
def authorize_as(user)

0 comments on commit 3cfb18d

Please sign in to comment.
Something went wrong with that request. Please try again.