summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorlambda <pleromagit@rogerbraun.net>2019-02-03 18:19:40 +0000
committerlambda <pleromagit@rogerbraun.net>2019-02-03 18:19:40 +0000
commit69a38644bc20f49390717f06be30cc2874f7b6f7 (patch)
tree68db3940ef91d35e1dc83f175716f126e15db716 /test
parent8180de951e2ac1efc6cfb9f64d078d6a1b7d0c0e (diff)
parente61f0be9518aff867f4c56f5102723eddbcf40f1 (diff)
downloadpleroma-69a38644bc20f49390717f06be30cc2874f7b6f7.tar.gz
pleroma-69a38644bc20f49390717f06be30cc2874f7b6f7.zip
Merge branch '589-fix-cache' into 'develop'
Resolve "Update object cache on favs/boosts" Closes #589 See merge request pleroma/pleroma!764
Diffstat (limited to 'test')
-rw-r--r--test/support/conn_case.ex1
-rw-r--r--test/support/data_case.ex1
-rw-r--r--test/web/mastodon_api/mastodon_api_controller_test.exs5
-rw-r--r--test/web/ostatus/ostatus_test.exs2
-rw-r--r--test/web/twitter_api/twitter_api_test.exs15
5 files changed, 24 insertions, 0 deletions
diff --git a/test/support/conn_case.ex b/test/support/conn_case.ex
index c201d9a9b..ec5892ff5 100644
--- a/test/support/conn_case.ex
+++ b/test/support/conn_case.ex
@@ -33,6 +33,7 @@ defmodule Pleroma.Web.ConnCase do
setup tags do
Cachex.clear(:user_cache)
+ Cachex.clear(:object_cache)
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Pleroma.Repo)
unless tags[:async] do
diff --git a/test/support/data_case.ex b/test/support/data_case.ex
index 56d5896ad..df260bd3f 100644
--- a/test/support/data_case.ex
+++ b/test/support/data_case.ex
@@ -32,6 +32,7 @@ defmodule Pleroma.DataCase do
setup tags do
Cachex.clear(:user_cache)
+ Cachex.clear(:object_cache)
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Pleroma.Repo)
unless tags[:async] do
diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs
index 141d300c7..8528d4f64 100644
--- a/test/web/mastodon_api/mastodon_api_controller_test.exs
+++ b/test/web/mastodon_api/mastodon_api_controller_test.exs
@@ -137,6 +137,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
end
test "posting a status with OGP link preview", %{conn: conn} do
+ Pleroma.Config.put([:rich_media, :enabled], true)
user = insert(:user)
conn =
@@ -148,6 +149,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
assert %{"id" => id, "card" => %{"title" => "The Rock"}} = json_response(conn, 200)
assert Repo.get(Activity, id)
+ Pleroma.Config.put([:rich_media, :enabled], false)
end
test "posting a direct status", %{conn: conn} do
@@ -1667,6 +1669,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
end
test "Status rich-media Card", %{conn: conn, user: user} do
+ Pleroma.Config.put([:rich_media, :enabled], true)
{:ok, activity} = CommonAPI.post(user, %{"status" => "http://example.com/ogp"})
response =
@@ -1691,6 +1694,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
}
}
}
+
+ Pleroma.Config.put([:rich_media, :enabled], false)
end
end
diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs
index 0c63dd84d..dbe5de2e2 100644
--- a/test/web/ostatus/ostatus_test.exs
+++ b/test/web/ostatus/ostatus_test.exs
@@ -530,6 +530,8 @@ defmodule Pleroma.Web.OStatusTest do
note_object.data
|> Map.put("type", "Article")
+ Cachex.clear(:object_cache)
+
cs = Object.change(note_object, %{data: note_data})
{:ok, _article_object} = Repo.update(cs)
diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs
index f94e2b873..48ddbcf50 100644
--- a/test/web/twitter_api/twitter_api_test.exs
+++ b/test/web/twitter_api/twitter_api_test.exs
@@ -200,12 +200,27 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
test "it favorites a status, returns the updated activity" do
user = insert(:user)
+ other_user = insert(:user)
note_activity = insert(:note_activity)
{:ok, status} = TwitterAPI.fav(user, note_activity.id)
updated_activity = Activity.get_by_ap_id(note_activity.data["id"])
+ assert ActivityView.render("activity.json", %{activity: updated_activity})["fave_num"] == 1
+
+ object = Object.normalize(note_activity.data["object"])
+
+ assert object.data["like_count"] == 1
assert status == updated_activity
+
+ {:ok, _status} = TwitterAPI.fav(other_user, note_activity.id)
+
+ object = Object.normalize(note_activity.data["object"])
+
+ assert object.data["like_count"] == 2
+
+ updated_activity = Activity.get_by_ap_id(note_activity.data["id"])
+ assert ActivityView.render("activity.json", %{activity: updated_activity})["fave_num"] == 2
end
test "it unfavorites a status, returns the updated activity" do