summaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional')
-rw-r--r--test/functional/api/users_controller_test.rb12
-rw-r--r--test/functional/keys_controller_test.rb14
2 files changed, 17 insertions, 9 deletions
diff --git a/test/functional/api/users_controller_test.rb b/test/functional/api/users_controller_test.rb
index b69770d..88ecae0 100644
--- a/test/functional/api/users_controller_test.rb
+++ b/test/functional/api/users_controller_test.rb
@@ -95,11 +95,13 @@ class Api::UsersControllerTest < ApiControllerTest
end
test "admin can show is_admin property" do
- user = FactoryGirl.create :user, login: "admin2"
- login user
- api_get :show, :id => user.id, :format => :json
- assert_response :success
- assert_json_response user.to_hash.merge(:is_admin => true)
+ admin = FactoryGirl.create :user
+ with_config(admins: [admin.login]) do
+ login admin
+ api_get :show, :id => admin.id, :format => :json
+ assert_response :success
+ assert_json_response admin.to_hash.merge(:is_admin => true)
+ end
end
test "normal users cannot show user" do
diff --git a/test/functional/keys_controller_test.rb b/test/functional/keys_controller_test.rb
index 863be93..1d437e7 100644
--- a/test/functional/keys_controller_test.rb
+++ b/test/functional/keys_controller_test.rb
@@ -2,6 +2,13 @@ require 'test_helper'
class KeysControllerTest < ActionController::TestCase
+ test "get key for username with dot" do
+ assert_routing 'key/username.with.dot', controller: 'keys',
+ action: 'show',
+ login: 'username.with.dot',
+ format: :text
+ end
+
test "get existing public key" do
public_key = 'my public key'
@user = stub_record :user, :public_key => public_key
@@ -23,10 +30,9 @@ class KeysControllerTest < ActionController::TestCase
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'
- }
+ # raise 404 error if user doesn't exist
+ get :show, :login => 'asdkljslksjfdlskfj'
+ assert_response :not_found
end
end