]> git.openstreetmap.org Git - rails.git/blobdiff - test/functional/user_controller_test.rb
Clean up search JS
[rails.git] / test / functional / user_controller_test.rb
index f756b0514a55d60159bb1287130936b321d4184c..606924b35d288fe12af91d31ead2aab2deaae0db 100644 (file)
@@ -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,30 @@ 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 "contributor-terms[pd]", false
+    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