summaryrefslogtreecommitdiff
path: root/users/test/support
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2013-08-27 14:55:43 +0200
committerAzul <azul@leap.se>2013-08-27 14:57:44 +0200
commit5e6a2a2995598489372676bf8e045dc2dfda6c81 (patch)
tree4b1d675191fededd08ad2329cb8b50e9eb74c92e /users/test/support
parent147ccec989672f9b1314aa6dcc5ce8578e841370 (diff)
token.user will get you the right user
This way we can stub the token to return the user directly. Stubbing User.find_by_param is not a good idea as it will make all calls to User#find_by_param with a different id fail.
Diffstat (limited to 'users/test/support')
-rw-r--r--users/test/support/auth_test_helper.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/users/test/support/auth_test_helper.rb b/users/test/support/auth_test_helper.rb
index ab6b1ac..47147fc 100644
--- a/users/test/support/auth_test_helper.rb
+++ b/users/test/support/auth_test_helper.rb
@@ -13,7 +13,7 @@ module AuthTestHelper
if user_or_method_hash.respond_to?(:reverse_merge)
user_or_method_hash.reverse_merge! :is_admin? => false
end
- @current_user = find_record(:user, user_or_method_hash)
+ @current_user = stub_record(:user, user_or_method_hash)
request.env['warden'] = stub :user => @current_user
request.env['HTTP_AUTHORIZATION'] = header_for_token_auth
return @current_user
@@ -41,7 +41,7 @@ module AuthTestHelper
protected
def header_for_token_auth
- @token = find_record(:token, :user_id => @current_user.id)
+ @token = find_record(:token, :user => @current_user)
ActionController::HttpAuthentication::Token.encode_credentials @token.id
end
end