]> git.openstreetmap.org Git - rails.git/blobdiff - test/functional/user_controller_test.rb
Fix test to make sure it picks up the right token
[rails.git] / test / functional / user_controller_test.rb
index c49073e683888d0019da30855c9afd29d79418ec..6a64fd8d81e40a40785da76d19ad43a0e1498f6a 100644 (file)
@@ -308,6 +308,16 @@ class UserControllerTest < ActionController::TestCase
     assert_select "form > fieldset > div.form-row > div.field_with_errors > input#user_display_name"
   end
 
+  def test_user_save_referer_params
+    user = new_user
+
+    post :save, {}, {:new_user => user,
+                     :referer => '/edit?editor=id#map=1/2/3'}
+
+    assert_equal welcome_path(:editor => 'id', :zoom => 1, :lat => 2, :lon => 3),
+                 user.tokens.order("id DESC").first.referer
+  end
+
   def test_user_confirm_expired_token
     user = users(:inactive_user)
     token = user.tokens.new
@@ -591,10 +601,33 @@ class UserControllerTest < ActionController::TestCase
     get :api_read, :id => users(:normal_user).id
     assert_response :success
 
+    # check the data that is returned
+    assert_select "description", :count => 1, :text => "test"
+    assert_select "contributor-terms", :count => 1 do
+      assert_select "[agreed=true]"
+    end
+    assert_select "img", :count => 1
+    assert_select "roles", :count => 1 do
+      assert_select "role", :count => 0
+    end
+    assert_select "changesets", :count => 1 do
+      assert_select "[count=0]"
+    end
+    assert_select "traces", :count => 1 do
+      assert_select "[count=0]"
+    end
+    assert_select "blocks", :count => 1 do
+      assert_select "received", :count => 1 do
+        assert_select "[count=0][active=0]"
+      end
+      assert_select "issued", :count => 0
+    end
+
     # check that we aren't revealing private information
     assert_select "contributor-terms[pd]", false
     assert_select "home", false
     assert_select "languages", false
+    assert_select "messages", false
 
     # check that a suspended user is not returned
     get :api_read, :id => users(:suspended_user).id
@@ -610,12 +643,50 @@ class UserControllerTest < ActionController::TestCase
   end
 
   def test_user_api_details
+    # check that nothing is returned when not logged in
     get :api_details
     assert_response :unauthorized
     
+    # check that we get a response when logged in
     basic_authorization(users(:normal_user).email, "test")
     get :api_details
     assert_response :success
+
+    # check the data that is returned
+    assert_select "description", :count => 1, :text => "test"
+    assert_select "contributor-terms", :count => 1 do
+      assert_select "[agreed=true][pd=false]"
+    end
+    assert_select "img", :count => 1
+    assert_select "roles", :count => 1 do
+      assert_select "role", :count => 0
+    end
+    assert_select "changesets", :count => 1 do
+      assert_select "[count=0]", :count => 1
+    end
+    assert_select "traces", :count => 1 do
+      assert_select "[count=0]", :count => 1
+    end
+    assert_select "blocks", :count => 1 do
+      assert_select "received", :count => 1 do
+        assert_select "[count=0][active=0]"
+      end
+      assert_select "issued", :count => 0
+    end
+    assert_select "home", :count => 1 do
+      assert_select "[lat=12.1][lon=12.1][zoom=3]"
+    end
+    assert_select "languages", :count => 1 do
+      assert_select "lang", :count => 1, :text => "en"
+    end
+    assert_select "messages", :count => 1 do
+      assert_select "received", :count => 1 do
+        assert_select "[count=1][unread=0]"
+      end
+      assert_select "sent", :count => 1 do
+        assert_select "[count=1]"
+      end
+    end
   end
 
   def test_user_make_friend