+
+ describe "parse_bio/2" do
+ test "preserves hosts in user links text" do
+ remote_user = insert(:user, local: false, nickname: "nick@domain.com")
+ user = insert(:user)
+ bio = "A.k.a. @nick@domain.com"
+
+ expected_text =
+ "A.k.a. <span class='h-card'><a data-user='#{remote_user.id}' class='u-url mention' href='#{
+ remote_user.ap_id
+ }'>@<span>nick@domain.com</span></a></span>"
+
+ assert expected_text == User.parse_bio(bio, user)
+ end
+
+ test "Adds rel=me on linkbacked urls" do
+ user = insert(:user, ap_id: "http://social.example.org/users/lain")
+
+ bio = "http://example.org/rel_me/null"
+ expected_text = "<a href=\"#{bio}\">#{bio}</a>"
+ assert expected_text == User.parse_bio(bio, user)
+
+ bio = "http://example.org/rel_me/link"
+ expected_text = "<a href=\"#{bio}\">#{bio}</a>"
+ assert expected_text == User.parse_bio(bio, user)
+
+ bio = "http://example.org/rel_me/anchor"
+ expected_text = "<a href=\"#{bio}\">#{bio}</a>"
+ assert expected_text == User.parse_bio(bio, user)
+ end
+ end
+
+ test "follower count is updated when a follower is blocked" do
+ user = insert(:user)
+ follower = insert(:user)
+ follower2 = insert(:user)
+ follower3 = insert(:user)
+
+ {:ok, follower} = Pleroma.User.follow(follower, user)
+ {:ok, _follower2} = Pleroma.User.follow(follower2, user)
+ {:ok, _follower3} = Pleroma.User.follow(follower3, user)
+
+ {:ok, _} = Pleroma.User.block(user, follower)
+
+ user_show = Pleroma.Web.TwitterAPI.UserView.render("show.json", %{user: user})
+
+ assert Map.get(user_show, "followers_count") == 2
+ end
+
+ describe "toggle_confirmation/1" do
+ test "if user is confirmed" do
+ user = insert(:user, info: %{confirmation_pending: false})
+ {:ok, user} = User.toggle_confirmation(user)
+
+ assert user.info.confirmation_pending
+ assert user.info.confirmation_token
+ end
+
+ test "if user is unconfirmed" do
+ user = insert(:user, info: %{confirmation_pending: true, confirmation_token: "some token"})
+ {:ok, user} = User.toggle_confirmation(user)
+
+ refute user.info.confirmation_pending
+ refute user.info.confirmation_token
+ end
+ end