X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/8dae890a7645fba17a44d84f78be03d993e22ccb..dfe21fec82a03d5313d1c78c5f0e2390f0aef287:/test/controllers/user_controller_test.rb diff --git a/test/controllers/user_controller_test.rb b/test/controllers/user_controller_test.rb index e149b83c7..d3cf5ef13 100644 --- a/test/controllers/user_controller_test.rb +++ b/test/controllers/user_controller_test.rb @@ -20,6 +20,10 @@ class UserControllerTest < ActionController::TestCase { :path => "/api/0.6/user/gpx_files", :method => :get }, { :controller => "user", :action => "api_gpx_files" } ) + assert_routing( + { :path => "/api/0.6/users", :method => :get }, + { :controller => "user", :action => "api_users" } + ) assert_routing( { :path => "/login", :method => :get }, @@ -567,7 +571,7 @@ class UserControllerTest < ActionController::TestCase stub_gravatar_request(user.new_email, 200) confirm_string = user.tokens.create.token # precondition gravatar should be turned off - assert !user.image_use_gravatar + assert_not user.image_use_gravatar post :confirm_email, :params => { :confirm_string => confirm_string } assert_response :redirect assert_redirected_to :action => :account, :display_name => user.display_name @@ -588,7 +592,7 @@ class UserControllerTest < ActionController::TestCase assert_redirected_to :action => :account, :display_name => user.display_name assert_match /Confirmed your change of email address/, flash[:notice] # gravatar use should now be disabled - assert !User.find(user.id).image_use_gravatar + assert_not User.find(user.id).image_use_gravatar end def test_terms_new_user @@ -1146,6 +1150,48 @@ class UserControllerTest < ActionController::TestCase end end + def test_api_users + user1 = create(:user, :description => "test1", :terms_agreed => Date.yesterday) + user2 = create(:user, :description => "test2", :terms_agreed => Date.yesterday) + user3 = create(:user, :description => "test3", :terms_agreed => Date.yesterday) + + get :api_users, :params => { :users => user1.id } + assert_response :success + assert_equal "text/xml", response.content_type + assert_select "user", :count => 1 do + assert_select "user[id='#{user1.id}']", :count => 1 + assert_select "user[id='#{user2.id}']", :count => 0 + assert_select "user[id='#{user3.id}']", :count => 0 + end + + get :api_users, :params => { :users => user2.id } + assert_response :success + assert_equal "text/xml", response.content_type + assert_select "user", :count => 1 do + assert_select "user[id='#{user1.id}']", :count => 0 + assert_select "user[id='#{user2.id}']", :count => 1 + assert_select "user[id='#{user3.id}']", :count => 0 + end + + get :api_users, :params => { :users => "#{user1.id},#{user3.id}" } + assert_response :success + assert_equal "text/xml", response.content_type + assert_select "user", :count => 2 do + assert_select "user[id='#{user1.id}']", :count => 1 + assert_select "user[id='#{user2.id}']", :count => 0 + assert_select "user[id='#{user3.id}']", :count => 1 + end + + get :api_users, :params => { :users => create(:user, :suspended).id } + assert_response :not_found + + get :api_users, :params => { :users => create(:user, :deleted).id } + assert_response :not_found + + get :api_users, :params => { :users => 0 } + assert_response :not_found + end + def test_api_gpx_files user = create(:user) trace1 = create(:trace, :user => user) do |trace|