X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/8e19a9bf7dde121903cd4135515f363a1a6c9d0d..3ce4de1295ecec082313740a3cdf25c2831164f7:/test/functional/user_controller_test.rb diff --git a/test/functional/user_controller_test.rb b/test/functional/user_controller_test.rb index f756b0514..afff1b2a8 100644 --- a/test/functional/user_controller_test.rb +++ b/test/functional/user_controller_test.rb @@ -6,6 +6,10 @@ class UserControllerTest < ActionController::TestCase ## # test all routes which lead to this controller def test_routes + assert_routing( + { :path => "/api/0.6/user/1", :method => :get }, + { :controller => "user", :action => "api_read", :id => "1" } + ) assert_routing( { :path => "/api/0.6/user/details", :method => :get }, { :controller => "user", :action => "api_details" } @@ -520,7 +524,29 @@ class UserControllerTest < ActionController::TestCase assert_select "a[href=/blocks/new/test]", 1 end end - + + def test_user_api_read + # check that a visible user is returned properly + get :api_read, :id => users(:normal_user).id + assert_response :success + + # check that we aren't revealing private information + assert_select "home", false + assert_select "languages", false + + # check that a suspended user is not returned + get :api_read, :id => users(:suspended_user).id + assert_response :gone + + # check that a deleted user is not returned + get :api_read, :id => users(:deleted_user).id + assert_response :gone + + # check that a non-existent user is not returned + get :api_read, :id => 0 + assert_response :not_found + end + def test_user_api_details get :api_details assert_response :unauthorized