summaryrefslogtreecommitdiff
path: root/users/test/support
diff options
context:
space:
mode:
Diffstat (limited to 'users/test/support')
-rw-r--r--users/test/support/auth_test_helper.rb24
1 files changed, 21 insertions, 3 deletions
diff --git a/users/test/support/auth_test_helper.rb b/users/test/support/auth_test_helper.rb
index c30421f..d5d52b1 100644
--- a/users/test/support/auth_test_helper.rb
+++ b/users/test/support/auth_test_helper.rb
@@ -1,7 +1,25 @@
module AuthTestHelper
- def assert_access_denied
- assert_equal({:alert => "Not authorized"}, flash.to_hash)
- assert_redirected_to login_path
+ 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
+ end
+
+ def stub_logged_out
+ @user_id = stub
+ session[:user_id] = @user_id
+ User.expects(:find).once.with(@user_id).returns(nil)
+ end
+
+ def assert_access_denied(denied = true)
+ if denied
+ assert_equal({:alert => "Not authorized"}, flash.to_hash)
+ assert_redirected_to login_path
+ else
+ assert flash[:alert].blank?
+ end
end
end