X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/2f9291ba5764fe104264ae7e3b6a361e11212e8b..de3ddafcd23753fd8055b03ecfe1cc4b11aacf83:/test/models/user_test.rb diff --git a/test/models/user_test.rb b/test/models/user_test.rb index a17c30deb..330f40df2 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -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