diff options
author | Azul <azul@leap.se> | 2012-11-04 17:57:03 +0100 |
---|---|---|
committer | Azul <azul@leap.se> | 2012-11-04 17:57:03 +0100 |
commit | c0f92bf9f481463dcaef6f4b30343130a8910a00 (patch) | |
tree | 3ba89c6f38d19a7b96a0ef599b7cb6364ba5821f /users/test/support | |
parent | b92d418ebec6486a9e728c57f38f82d4c3343341 (diff) | |
parent | 19008253d01fd6d7a864e98a7ae5dc216070aee1 (diff) |
Merge branch 'develop' into feature-warden-srp
Conflicts:
Gemfile.lock
users/app/controllers/application_controller.rb
users/leap_web_users.gemspec
Diffstat (limited to 'users/test/support')
-rw-r--r-- | users/test/support/auth_test_helper.rb | 29 |
1 files changed, 29 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..9412058 --- /dev/null +++ b/users/test/support/auth_test_helper.rb @@ -0,0 +1,29 @@ +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 + +class ActionController::TestCase + include AuthTestHelper +end |