summaryrefslogtreecommitdiff
path: root/users/test/functional
diff options
context:
space:
mode:
authorjessib <jessib@riseup.net>2013-11-21 12:15:03 -0800
committerjessib <jessib@riseup.net>2013-11-21 12:15:03 -0800
commitd82ea5da2aa705bcfa74f2a8b42a197883b694e3 (patch)
tree3b65497d551a611baa23791a3febce472eab0291 /users/test/functional
parent15b234bf798f3c6347f3c5a13fd1ddfdb744354d (diff)
Refactoring of code, and tests.
Diffstat (limited to 'users/test/functional')
-rw-r--r--users/test/functional/keys_controller_test.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/users/test/functional/keys_controller_test.rb b/users/test/functional/keys_controller_test.rb
new file mode 100644
index 0000000..9cc88d1
--- /dev/null
+++ b/users/test/functional/keys_controller_test.rb
@@ -0,0 +1,31 @@
+require 'test_helper'
+
+class KeysControllerTest < ActionController::TestCase
+
+ test "get existing public key" do
+ public_key = 'my public key'
+ @user = stub_record :user, :public_key => public_key
+ User.stubs(:find_by_login).with(@user.login).returns(@user)
+ get :show, :login => @user.login
+ assert_response :success
+ assert_equal "text/html", response.content_type
+ assert_equal public_key, response.body
+ end
+
+ test "get non-existing public key for user" do
+ @user = stub_record :user
+ User.stubs(:find_by_login).with(@user.login).returns(@user)
+ get :show, :login => @user.login
+ assert_response :success
+ assert_equal "text/html", response.content_type
+ assert_equal '', response.body.strip
+ end
+
+ test "get public key for non-existing user" do
+ get :show, :login => 'asdkljslksjfdlskfj'
+ assert_response :success
+ assert_equal "text/html", response.content_type
+ assert_equal '', response.body.strip
+ end
+
+end