]> git.openstreetmap.org Git - rails.git/blobdiff - test/controllers/user_controller_test.rb
Be explicit in which traces are expected.
[rails.git] / test / controllers / user_controller_test.rb
index 6a5fca78563af0077ae27c80c2dceb33032dbcbf..9e499b60596e2a0096fc617d574db14859cf0f72 100644 (file)
@@ -2,7 +2,6 @@ require "test_helper"
 
 class UserControllerTest < ActionController::TestCase
   api_fixtures
-  fixtures :messages
 
   ##
   # test all routes which lead to this controller
@@ -805,7 +804,7 @@ class UserControllerTest < ActionController::TestCase
     assert_select "form#accountForm > fieldset > div.form-row > select#user_preferred_editor > option[selected]", false
 
     # Changing to an uploaded image should work
-    image = Rack::Test::UploadedFile.new("test/traces/1.gif", "image/gif")
+    image = Rack::Test::UploadedFile.new("test/traces/a.gif", "image/gif")
     post :account, { :display_name => user.display_name, :image_action => "new", :user => user.attributes.merge(:image => image) }, { :user => user.id }
     assert_response :success
     assert_template :account
@@ -924,6 +923,7 @@ class UserControllerTest < ActionController::TestCase
     end
 
     # Test a user who has been blocked
+    create(:user_block, :user => users(:blocked_user))
     get :view, :display_name => "blocked"
     assert_response :success
     assert_select "div#userinformation" do
@@ -938,6 +938,7 @@ class UserControllerTest < ActionController::TestCase
     end
 
     # Test a moderator who has applied blocks
+    create(:user_block, :creator => users(:moderator_user))
     get :view, :display_name => "moderator"
     assert_response :success
     assert_select "div#userinformation" do
@@ -1034,6 +1035,8 @@ class UserControllerTest < ActionController::TestCase
   end
 
   def test_api_details
+    create(:message, :read, :recipient => users(:normal_user))
+
     # check that nothing is returned when not logged in
     get :api_details
     assert_response :unauthorized
@@ -1082,6 +1085,12 @@ class UserControllerTest < ActionController::TestCase
   end
 
   def test_api_gpx_files
+    trace1 = create(:trace, :user => users(:normal_user)) do |trace|
+      create(:tracetag, :trace => trace, :tag => "London")
+    end
+    trace2 = create(:trace, :user => users(:normal_user)) do |trace|
+      create(:tracetag, :trace => trace, :tag => "Birmingham")
+    end
     # check that nothing is returned when not logged in
     get :api_gpx_files
     assert_response :unauthorized
@@ -1093,10 +1102,10 @@ class UserControllerTest < ActionController::TestCase
     assert_equal "text/xml", response.content_type
 
     # check the data that is returned
-    assert_select "gpx_file[id='1']", 1 do
+    assert_select "gpx_file[id='#{trace1.id}']", 1 do
       assert_select "tag", "London"
     end
-    assert_select "gpx_file[id='4']", 1 do
+    assert_select "gpx_file[id='#{trace2.id}']", 1 do
       assert_select "tag", "Birmingham"
     end
   end
@@ -1191,7 +1200,7 @@ class UserControllerTest < ActionController::TestCase
     # Get users to work with
     user = users(:normal_user)
     friend = users(:public_user)
-    create(:friend, :user_id => user.id, :friend_user_id => friend.id)
+    create(:friend, :befriender => user, :befriendee => friend)
 
     # Check that the users are friends
     assert Friend.where(:user_id => user.id, :friend_user_id => friend.id).first