diff options
author | jessib <jessib@riseup.net> | 2012-11-02 11:12:15 -0700 |
---|---|---|
committer | jessib <jessib@riseup.net> | 2012-11-02 11:12:15 -0700 |
commit | 4db41d772725387ba36240cf8f3529780e896755 (patch) | |
tree | 4c4e0f7651ee100f93273775ec934dba1a934724 /users/test/support/auth_test_helper.rb | |
parent | 8b5f7fb6ef438ef034541d6fb500b5ab7e12f3f2 (diff) | |
parent | 872b9fa6759d5708f5efb19ba46b3c8e2b5d4862 (diff) |
Merge branch 'feature-admin_users' into help_develop
Diffstat (limited to 'users/test/support/auth_test_helper.rb')
-rw-r--r-- | users/test/support/auth_test_helper.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/users/test/support/auth_test_helper.rb b/users/test/support/auth_test_helper.rb new file mode 100644 index 0000000..d5d52b1 --- /dev/null +++ b/users/test/support/auth_test_helper.rb @@ -0,0 +1,25 @@ +module AuthTestHelper + + 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 |