summaryrefslogtreecommitdiff
path: root/users/test/functional/keys_controller_test.rb
diff options
context:
space:
mode:
authorazul <azul@riseup.net>2013-11-25 13:12:20 -0800
committerazul <azul@riseup.net>2013-11-25 13:12:20 -0800
commit21cc6313320efa2992a58b7434468678ca6cf3b6 (patch)
tree13f878e171d1cbbbcc82f5e40c91db145017efb2 /users/test/functional/keys_controller_test.rb
parent19eac22510fcb4ad74456cc3872196fa1e63a93d (diff)
parent299dfdf4164ee10de63aa2543935eeed65437b3f (diff)
Merge pull request #117 from jessib/feature/return_public_key
Feature/return public key
Diffstat (limited to 'users/test/functional/keys_controller_test.rb')
-rw-r--r--users/test/functional/keys_controller_test.rb32
1 files changed, 32 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..b69cbc0
--- /dev/null
+++ b/users/test/functional/keys_controller_test.rb
@@ -0,0 +1,32 @@
+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
+ # this isn't a scenerio that should generally occur.
+ @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
+ # raise 404 error if user doesn't exist (doesn't need to be this routing error, but seems fine to assume for now):
+ assert_raise(ActionController::RoutingError) {
+ get :show, :login => 'asdkljslksjfdlskfj'
+ }
+ end
+
+end