]> git.openstreetmap.org Git - rails.git/blobdiff - test/models/user_test.rb
Merge pull request #2809 from tomhughes/bootstrap
[rails.git] / test / models / user_test.rb
index a17c30deb5eded5191d4e99ff872696d3efc97da..330f40df28d13bf4e7ac3579a76109fefbb29345 100644 (file)
@@ -26,7 +26,7 @@ class UserTest < ActiveSupport::TestCase
       :description => "desc"
     )
     assert_not new_user.save
-    assert new_user.errors[:email].include?("has already been taken")
+    assert_includes new_user.errors[:email], "has already been taken"
   end
 
   def test_unique_display_name
@@ -40,7 +40,7 @@ class UserTest < ActiveSupport::TestCase
       :description => "desc"
     )
     assert_not new_user.save
-    assert new_user.errors[:display_name].include?("has already been taken")
+    assert_includes new_user.errors[:display_name], "has already been taken"
   end
 
   def test_email_valid
@@ -105,7 +105,7 @@ class UserTest < ActiveSupport::TestCase
     alice = create(:user, :active)
     bob = create(:user, :active)
     charlie = create(:user, :active)
-    create(:friend, :befriender => alice, :befriendee => bob)
+    create(:friendship, :befriender => alice, :befriendee => bob)
 
     assert alice.is_friends_with?(bob)
     assert_not alice.is_friends_with?(charlie)
@@ -136,16 +136,16 @@ class UserTest < ActiveSupport::TestCase
     assert_equal [], vagrant_user.nearby
   end
 
-  def test_friend_users
+  def test_friends
     norm = create(:user, :active)
     sec = create(:user, :active)
-    create(:friend, :befriender => norm, :befriendee => sec)
+    create(:friendship, :befriender => norm, :befriendee => sec)
 
-    assert_equal [sec], norm.friend_users
-    assert_equal 1, norm.friend_users.size
+    assert_equal [sec], norm.friends
+    assert_equal 1, norm.friends.size
 
-    assert_equal [], sec.friend_users
-    assert_equal 0, sec.friend_users.size
+    assert_equal [], sec.friends
+    assert_equal 0, sec.friends.size
   end
 
   def test_user_preferred_editor
@@ -224,36 +224,36 @@ class UserTest < ActiveSupport::TestCase
   end
 
   def test_visible?
-    assert_equal true, build(:user, :pending).visible?
-    assert_equal true, build(:user, :active).visible?
-    assert_equal true, build(:user, :confirmed).visible?
-    assert_equal false, build(:user, :suspended).visible?
-    assert_equal false, build(:user, :deleted).visible?
+    assert build(:user, :pending).visible?
+    assert build(:user, :active).visible?
+    assert build(:user, :confirmed).visible?
+    assert_not build(:user, :suspended).visible?
+    assert_not build(:user, :deleted).visible?
   end
 
   def test_active?
-    assert_equal false, build(:user, :pending).active?
-    assert_equal true, build(:user, :active).active?
-    assert_equal true, build(:user, :confirmed).active?
-    assert_equal false, build(:user, :suspended).active?
-    assert_equal false, build(:user, :deleted).active?
+    assert_not build(:user, :pending).active?
+    assert build(:user, :active).active?
+    assert build(:user, :confirmed).active?
+    assert_not build(:user, :suspended).active?
+    assert_not build(:user, :deleted).active?
   end
 
   def test_moderator?
-    assert_equal false, create(:user).moderator?
-    assert_equal true, create(:moderator_user).moderator?
+    assert_not create(:user).moderator?
+    assert create(:moderator_user).moderator?
   end
 
   def test_administrator?
-    assert_equal false, create(:user).administrator?
-    assert_equal true, create(:administrator_user).administrator?
+    assert_not create(:user).administrator?
+    assert create(:administrator_user).administrator?
   end
 
   def test_has_role?
-    assert_equal false, create(:user).has_role?("administrator")
-    assert_equal false, create(:user).has_role?("moderator")
-    assert_equal true, create(:administrator_user).has_role?("administrator")
-    assert_equal true, create(:moderator_user).has_role?("moderator")
+    assert_not create(:user).has_role?("administrator")
+    assert_not create(:user).has_role?("moderator")
+    assert create(:administrator_user).has_role?("administrator")
+    assert create(:moderator_user).has_role?("moderator")
   end
 
   def test_delete
@@ -263,10 +263,10 @@ class UserTest < ActiveSupport::TestCase
     assert user.description.blank?
     assert_nil user.home_lat
     assert_nil user.home_lon
-    assert_equal false, user.image.file?
+    assert_not user.avatar.attached?
     assert_equal "deleted", user.status
-    assert_equal false, user.visible?
-    assert_equal false, user.active?
+    assert_not user.visible?
+    assert_not user.active?
   end
 
   def test_to_xml