summaryrefslogtreecommitdiff
path: root/users/test/functional
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2013-08-27 11:14:30 +0200
committerAzul <azul@leap.se>2013-08-27 14:57:44 +0200
commite60ee749cab0f80cf23ca57e28c7de6d1b3a395b (patch)
tree9c647de3952d8f8fe78fc4fcb06de0d504c436d5 /users/test/functional
parent7ad6d054d72d3c76098f689e4e7890265a3604c8 (diff)
basic testing for token based auth in tests
Diffstat (limited to 'users/test/functional')
-rw-r--r--users/test/functional/helper_methods_test.rb2
-rw-r--r--users/test/functional/test_helpers_test.rb38
2 files changed, 39 insertions, 1 deletions
diff --git a/users/test/functional/helper_methods_test.rb b/users/test/functional/helper_methods_test.rb
index 2b2375c..44226ae 100644
--- a/users/test/functional/helper_methods_test.rb
+++ b/users/test/functional/helper_methods_test.rb
@@ -11,7 +11,7 @@ class HelperMethodsTest < ActionController::TestCase
# we test them right in here...
include ApplicationController._helpers
- # they all reference the controller.
+ # the helpers all reference the controller.
def controller
@controller
end
diff --git a/users/test/functional/test_helpers_test.rb b/users/test/functional/test_helpers_test.rb
new file mode 100644
index 0000000..d1bdb64
--- /dev/null
+++ b/users/test/functional/test_helpers_test.rb
@@ -0,0 +1,38 @@
+#
+# There are a few test helpers for dealing with login etc.
+# We test them here and also document their behaviour.
+#
+
+require 'test_helper'
+
+class TestHelpersTest < ActionController::TestCase
+ tests ApplicationController # testing no controller in particular
+
+ def test_login_stubs_warden
+ login
+ assert_equal @current_user, request.env['warden'].user
+ end
+
+ def test_login_token_authenticates
+ login
+ assert_equal @current_user, @controller.send(:token_authenticate)
+ end
+
+ def test_login_stubs_token
+ login
+ assert @token
+ assert_equal @current_user.id, @token.user_id
+ end
+
+ def test_login_adds_token_header
+ login
+ token_present = @controller.authenticate_with_http_token do |token, options|
+ assert_equal @token.id, token
+ end
+ # authenticate_with_http_token just returns nil and does not
+ # execute the block if there is no token. So we have to also
+ # ensure it was run:
+ assert token_present
+ end
+end
+