summaryrefslogtreecommitdiff
path: root/users/test/support
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2012-11-12 19:42:00 +0100
committerAzul <azul@leap.se>2012-11-12 19:42:00 +0100
commita0ba5ec9c705a74b86fdb558436fb05103bf88e3 (patch)
tree22e0562166e38eb84dc20c8e7addf3089b3af13c /users/test/support
parent05ea71016fd54a14159c72299c25efbdc2f177bc (diff)
parentfe8b49232d31681667badaaeff7aa4d0a40445ea (diff)
Merge branch 'develop' into feature-client-side-validations
Conflicts: Gemfile.lock
Diffstat (limited to 'users/test/support')
-rw-r--r--users/test/support/auth_test_helper.rb21
1 files changed, 11 insertions, 10 deletions
diff --git a/users/test/support/auth_test_helper.rb b/users/test/support/auth_test_helper.rb
index 9412058..f211597 100644
--- a/users/test/support/auth_test_helper.rb
+++ b/users/test/support/auth_test_helper.rb
@@ -1,17 +1,18 @@
module AuthTestHelper
+ extend ActiveSupport::Concern
- def stub_logged_in
- @user_id = stub
- @user = stub
- session[:user_id] = @user_id
- User.expects(:find).once.with(@user_id).returns(@user)
- return @user
+ # Controller will fetch current user from warden.
+ # Make it pick up our current_user
+ included do
+ setup do
+ request.env['warden'] ||= stub :user => nil
+ end
end
- def stub_logged_out
- @user_id = stub
- session[:user_id] = @user_id
- User.expects(:find).once.with(@user_id).returns(nil)
+ def login(user = nil)
+ @current_user = user || stub
+ request.env['warden'] = stub :user => @current_user
+ return @current_user
end
def assert_access_denied(denied = true)