summaryrefslogtreecommitdiff
path: root/users/test/functional
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2012-11-04 21:01:27 +0100
committerAzul <azul@leap.se>2012-11-04 21:01:27 +0100
commite1fc3f4850ee73e0591bd67a92b104db4f63e4cb (patch)
tree1207ce14cb1c2551a3fda09e7c670cc97182a0f6 /users/test/functional
parentc0f92bf9f481463dcaef6f4b30343130a8910a00 (diff)
stubbing current_user the warden way
Diffstat (limited to 'users/test/functional')
-rw-r--r--users/test/functional/application_controller_test.rb7
-rw-r--r--users/test/functional/helper_methods_test.rb15
2 files changed, 9 insertions, 13 deletions
diff --git a/users/test/functional/application_controller_test.rb b/users/test/functional/application_controller_test.rb
index 69bcb2f..857bae5 100644
--- a/users/test/functional/application_controller_test.rb
+++ b/users/test/functional/application_controller_test.rb
@@ -8,20 +8,19 @@ class ApplicationControllerTest < ActionController::TestCase
end
def test_authorize_redirect
- stub_logged_out
@controller.send(:authorize)
assert_access_denied
end
def test_authorized
- @user = stub_logged_in
+ login
@controller.send(:authorize)
assert_access_denied(false)
end
def test_authorize_admin
- @user = stub_logged_in
- @user.expects(:is_admin?).returns(false)
+ login
+ @current_user.expects(:is_admin?).returns(false)
@controller.send(:authorize_admin)
assert_access_denied
end
diff --git a/users/test/functional/helper_methods_test.rb b/users/test/functional/helper_methods_test.rb
index c0eaf61..2b2375c 100644
--- a/users/test/functional/helper_methods_test.rb
+++ b/users/test/functional/helper_methods_test.rb
@@ -16,26 +16,23 @@ class HelperMethodsTest < ActionController::TestCase
@controller
end
- def test_current_user_with_caching
- @user = stub_logged_in
- assert_equal @user, current_user
- assert_equal @user, current_user # tests caching
+ def test_current_user
+ login
+ assert_equal @current_user, current_user
end
def test_logged_in
- @user = stub_logged_in
+ login
assert logged_in?
end
def test_logged_out
- stub_logged_out
assert !logged_in?
end
def test_admin
- bool = stub
- @user = stub_logged_in
- @user.expects(:is_admin?).returns(bool)
+ login
+ @current_user.expects(:is_admin?).returns(bool = stub)
assert_equal bool, admin?
end