]> git.openstreetmap.org Git - rails.git/commitdiff
Convert test_friend_with to use factories, and use alice/bob/charlie for easier under...
authorAndy Allan <git@gravitystorm.co.uk>
Thu, 2 Feb 2017 13:20:51 +0000 (13:20 +0000)
committerAndy Allan <git@gravitystorm.co.uk>
Thu, 2 Feb 2017 13:20:51 +0000 (13:20 +0000)
test/models/user_test.rb

index 3f66c5827460e96ab9b25e1a0cb7407f044d827d..dd2f9691d38432090760ec138b55e899d9b1144a 100644 (file)
@@ -108,13 +108,17 @@ class UserTest < ActiveSupport::TestCase
   end
 
   def test_friend_with
-    create(:friend, :befriender => users(:normal_user), :befriendee => users(:public_user))
-    assert users(:normal_user).is_friends_with?(users(:public_user))
-    assert !users(:normal_user).is_friends_with?(users(:inactive_user))
-    assert !users(:public_user).is_friends_with?(users(:normal_user))
-    assert !users(:public_user).is_friends_with?(users(:inactive_user))
-    assert !users(:inactive_user).is_friends_with?(users(:normal_user))
-    assert !users(:inactive_user).is_friends_with?(users(:public_user))
+    alice = create(:user, :active)
+    bob = create(:user, :active)
+    charlie = create(:user, :active)
+    create(:friend, :befriender => alice, :befriendee => bob)
+
+    assert alice.is_friends_with?(bob)
+    assert !alice.is_friends_with?(charlie)
+    assert !bob.is_friends_with?(alice)
+    assert !bob.is_friends_with?(charlie)
+    assert !charlie.is_friends_with?(bob)
+    assert !charlie.is_friends_with?(alice)
   end
 
   def test_users_nearby