aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/pleroma/web/common_api/utils.ex2
-rw-r--r--test/web/mastodon_api/mastodon_api_controller_test.exs4
-rw-r--r--test/web/mastodon_api/status_view_test.exs4
-rw-r--r--test/web/twitter_api/twitter_api_test.exs4
-rw-r--r--test/web/twitter_api/views/user_view_test.exs4
5 files changed, 10 insertions, 8 deletions
diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex
index e60dff7dc..2b359dd72 100644
--- a/lib/pleroma/web/common_api/utils.ex
+++ b/lib/pleroma/web/common_api/utils.ex
@@ -95,7 +95,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do
Enum.reduce(mentions, step_one, fn ({match, %User{ap_id: ap_id}, uuid}, text) ->
short_match = String.split(match, "@") |> tl() |> hd()
- String.replace(text, uuid, "<a href='#{ap_id}'>@#{short_match}</a>")
+ String.replace(text, uuid, "<span><a href='#{ap_id}'>@<span>#{short_match}</span></a></span>")
end)
end
diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs
index fc0010569..8bfad5265 100644
--- a/test/web/mastodon_api/mastodon_api_controller_test.exs
+++ b/test/web/mastodon_api/mastodon_api_controller_test.exs
@@ -145,7 +145,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|> assign(:user, user)
|> get("/api/v1/notifications")
- expected_response = "hi <a href=\"#{user.ap_id}\">@#{user.nickname}</a>"
+ expected_response = "hi <span><a href=\"#{user.ap_id}\">@<span>#{user.nickname}</span></a></span>"
assert [%{"status" => %{"content" => response}} | _rest] = json_response(conn, 200)
assert response == expected_response
end
@@ -161,7 +161,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|> assign(:user, user)
|> get("/api/v1/notifications/#{notification.id}")
- expected_response = "hi <a href=\"#{user.ap_id}\">@#{user.nickname}</a>"
+ expected_response = "hi <span><a href=\"#{user.ap_id}\">@<span>#{user.nickname}</span></a></span>"
assert %{"status" => %{"content" => response}} = json_response(conn, 200)
assert response == expected_response
end
diff --git a/test/web/mastodon_api/status_view_test.exs b/test/web/mastodon_api/status_view_test.exs
index 93c0b7236..0d396f3b8 100644
--- a/test/web/mastodon_api/status_view_test.exs
+++ b/test/web/mastodon_api/status_view_test.exs
@@ -56,7 +56,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
test "contains mentions" do
incoming = File.read!("test/fixtures/incoming_reply_mastodon.xml")
- user = insert(:user, %{ap_id: "https://pleroma.soykaf.com/users/lain"})
+ # a user with this ap id might be in the cache.
+ recipient = "https://pleroma.soykaf.com/users/lain"
+ user = User.get_cached_by_ap_id(recipient) || insert(:user, %{ap_id: recipient})
{:ok, [activity]} = OStatus.handle_incoming(incoming)
diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs
index 96552f97e..823ba3913 100644
--- a/test/web/twitter_api/twitter_api_test.exs
+++ b/test/web/twitter_api/twitter_api_test.exs
@@ -34,7 +34,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
{ :ok, activity = %Activity{} } = TwitterAPI.create_status(user, input)
- assert get_in(activity.data, ["object", "content"]) == "Hello again, <a href='shp'>@shp</a>.&lt;script&gt;&lt;/script&gt;<br>This is on another :moominmamma: line. #2hu #epic #phantasmagoric<br><a href=\"http://example.org/image.jpg\" class='attachment'>image.jpg</a>"
+ assert get_in(activity.data, ["object", "content"]) == "Hello again, <span><a href='shp'>@<span>shp</span></a></span>.&lt;script&gt;&lt;/script&gt;<br>This is on another :moominmamma: line. #2hu #epic #phantasmagoric<br><a href=\"http://example.org/image.jpg\" class='attachment'>image.jpg</a>"
assert get_in(activity.data, ["object", "type"]) == "Note"
assert get_in(activity.data, ["object", "actor"]) == user.ap_id
assert get_in(activity.data, ["actor"]) == user.ap_id
@@ -291,7 +291,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
archaeme_remote = insert(:user, %{nickname: "archaeme@archae.me"})
mentions = Pleroma.Formatter.parse_mentions(text)
- expected_text = "<a href='#{gsimg.ap_id}'>@gsimg</a> According to <a href='#{archaeme.ap_id}'>@archaeme</a>, that is @daggsy. Also hello <a href='#{archaeme_remote.ap_id}'>@archaeme</a>"
+ expected_text = "<span><a href='#{gsimg.ap_id}'>@<span>gsimg</span></a></span> According to <span><a href='#{archaeme.ap_id}'>@<span>archaeme</span></a></span>, that is @daggsy. Also hello <span><a href='#{archaeme_remote.ap_id}'>@<span>archaeme</span></a></span>"
assert Utils.add_user_links(text, mentions) == expected_text
end
diff --git a/test/web/twitter_api/views/user_view_test.exs b/test/web/twitter_api/views/user_view_test.exs
index 18a19ef70..753e41d20 100644
--- a/test/web/twitter_api/views/user_view_test.exs
+++ b/test/web/twitter_api/views/user_view_test.exs
@@ -30,8 +30,8 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
User.follow(follower, user)
User.follow(second_follower, user)
User.follow(user, follower)
-
- user = Repo.get!(User, user.id)
+ {:ok, user} = User.update_follower_count(user)
+ Cachex.set(:user_cache, "user_info:#{user.id}", User.user_info(Repo.get!(User, user.id)))
image = "https://placehold.it/48x48"