Merge branch 'get_by_id' into 'develop'
Replace `Repo.get(Module, id)` with `Module.get_by_id(id)` where possible See merge request pleroma/pleroma!1009
This commit is contained in:
commit
26d509cc86
29 changed files with 155 additions and 161 deletions
|
|
@ -122,7 +122,7 @@ defmodule Pleroma.UserTest do
|
|||
|
||||
{:ok, user} = User.follow(user, followed)
|
||||
|
||||
user = Repo.get(User, user.id)
|
||||
user = User.get_by_id(user.id)
|
||||
|
||||
followed = User.get_by_ap_id(followed.ap_id)
|
||||
assert followed.info.follower_count == 1
|
||||
|
|
@ -178,7 +178,7 @@ defmodule Pleroma.UserTest do
|
|||
|
||||
{:ok, user, _activity} = User.unfollow(user, followed)
|
||||
|
||||
user = Repo.get(User, user.id)
|
||||
user = User.get_by_id(user.id)
|
||||
|
||||
assert user.following == []
|
||||
end
|
||||
|
|
@ -188,7 +188,7 @@ defmodule Pleroma.UserTest do
|
|||
|
||||
{:error, _} = User.unfollow(user, user)
|
||||
|
||||
user = Repo.get(User, user.id)
|
||||
user = User.get_by_id(user.id)
|
||||
assert user.following == [user.ap_id]
|
||||
end
|
||||
|
||||
|
|
@ -686,7 +686,7 @@ defmodule Pleroma.UserTest do
|
|||
assert User.following?(blocked, blocker)
|
||||
|
||||
{:ok, blocker} = User.block(blocker, blocked)
|
||||
blocked = Repo.get(User, blocked.id)
|
||||
blocked = User.get_by_id(blocked.id)
|
||||
|
||||
assert User.blocks?(blocker, blocked)
|
||||
|
||||
|
|
@ -704,7 +704,7 @@ defmodule Pleroma.UserTest do
|
|||
refute User.following?(blocked, blocker)
|
||||
|
||||
{:ok, blocker} = User.block(blocker, blocked)
|
||||
blocked = Repo.get(User, blocked.id)
|
||||
blocked = User.get_by_id(blocked.id)
|
||||
|
||||
assert User.blocks?(blocker, blocked)
|
||||
|
||||
|
|
@ -722,7 +722,7 @@ defmodule Pleroma.UserTest do
|
|||
assert User.following?(blocked, blocker)
|
||||
|
||||
{:ok, blocker} = User.block(blocker, blocked)
|
||||
blocked = Repo.get(User, blocked.id)
|
||||
blocked = User.get_by_id(blocked.id)
|
||||
|
||||
assert User.blocks?(blocker, blocked)
|
||||
|
||||
|
|
@ -816,9 +816,9 @@ defmodule Pleroma.UserTest do
|
|||
|
||||
{:ok, _} = User.delete(user)
|
||||
|
||||
followed = Repo.get(User, followed.id)
|
||||
follower = Repo.get(User, follower.id)
|
||||
user = Repo.get(User, user.id)
|
||||
followed = User.get_by_id(followed.id)
|
||||
follower = User.get_by_id(follower.id)
|
||||
user = User.get_by_id(user.id)
|
||||
|
||||
assert user.info.deactivated
|
||||
|
||||
|
|
@ -827,7 +827,7 @@ defmodule Pleroma.UserTest do
|
|||
|
||||
# TODO: Remove favorites, repeats, delete activities.
|
||||
|
||||
refute Repo.get(Activity, activity.id)
|
||||
refute Activity.get_by_id(activity.id)
|
||||
end
|
||||
|
||||
test "get_public_key_for_ap_id fetches a user that's not in the db" do
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
|||
alias Pleroma.Activity
|
||||
alias Pleroma.Instances
|
||||
alias Pleroma.Object
|
||||
alias Pleroma.Repo
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Web.ActivityPub.ObjectView
|
||||
alias Pleroma.Web.ActivityPub.UserView
|
||||
|
|
@ -51,7 +50,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
|||
|> put_req_header("accept", "application/json")
|
||||
|> get("/users/#{user.nickname}")
|
||||
|
||||
user = Repo.get(User, user.id)
|
||||
user = User.get_by_id(user.id)
|
||||
|
||||
assert json_response(conn, 200) == UserView.render("user.json", %{user: user})
|
||||
end
|
||||
|
|
@ -66,7 +65,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
|||
|> put_req_header("accept", "application/activity+json")
|
||||
|> get("/users/#{user.nickname}")
|
||||
|
||||
user = Repo.get(User, user.id)
|
||||
user = User.get_by_id(user.id)
|
||||
|
||||
assert json_response(conn, 200) == UserView.render("user.json", %{user: user})
|
||||
end
|
||||
|
|
@ -84,7 +83,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
|||
)
|
||||
|> get("/users/#{user.nickname}")
|
||||
|
||||
user = Repo.get(User, user.id)
|
||||
user = User.get_by_id(user.id)
|
||||
|
||||
assert json_response(conn, 200) == UserView.render("user.json", %{user: user})
|
||||
end
|
||||
|
|
@ -543,7 +542,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
|||
user = insert(:user)
|
||||
|
||||
Enum.each(1..15, fn _ ->
|
||||
user = Repo.get(User, user.id)
|
||||
user = User.get_by_id(user.id)
|
||||
other_user = insert(:user)
|
||||
User.follow(user, other_user)
|
||||
end)
|
||||
|
|
|
|||
|
|
@ -218,18 +218,18 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
user = insert(:user)
|
||||
|
||||
{:ok, _} =
|
||||
CommonAPI.post(Repo.get(User, user.id), %{"status" => "1", "visibility" => "public"})
|
||||
CommonAPI.post(User.get_by_id(user.id), %{"status" => "1", "visibility" => "public"})
|
||||
|
||||
{:ok, _} =
|
||||
CommonAPI.post(Repo.get(User, user.id), %{"status" => "2", "visibility" => "unlisted"})
|
||||
CommonAPI.post(User.get_by_id(user.id), %{"status" => "2", "visibility" => "unlisted"})
|
||||
|
||||
{:ok, _} =
|
||||
CommonAPI.post(Repo.get(User, user.id), %{"status" => "2", "visibility" => "private"})
|
||||
CommonAPI.post(User.get_by_id(user.id), %{"status" => "2", "visibility" => "private"})
|
||||
|
||||
{:ok, _} =
|
||||
CommonAPI.post(Repo.get(User, user.id), %{"status" => "3", "visibility" => "direct"})
|
||||
CommonAPI.post(User.get_by_id(user.id), %{"status" => "3", "visibility" => "direct"})
|
||||
|
||||
user = Repo.get(User, user.id)
|
||||
user = User.get_by_id(user.id)
|
||||
assert user.info.note_count == 2
|
||||
end
|
||||
|
||||
|
|
@ -322,7 +322,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
{:ok, user} = User.block(user, %{ap_id: activity_three.data["actor"]})
|
||||
{:ok, _announce, %{data: %{"id" => id}}} = CommonAPI.repeat(activity_three.id, booster)
|
||||
%Activity{} = boost_activity = Activity.get_create_by_object_ap_id(id)
|
||||
activity_three = Repo.get(Activity, activity_three.id)
|
||||
activity_three = Activity.get_by_id(activity_three.id)
|
||||
|
||||
activities =
|
||||
ActivityPub.fetch_activities([], %{"blocking_user" => user, "skip_preload" => true})
|
||||
|
|
@ -380,7 +380,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
{:ok, user} = User.mute(user, %User{ap_id: activity_three.data["actor"]})
|
||||
{:ok, _announce, %{data: %{"id" => id}}} = CommonAPI.repeat(activity_three.id, booster)
|
||||
%Activity{} = boost_activity = Activity.get_create_by_object_ap_id(id)
|
||||
activity_three = Repo.get(Activity, activity_three.id)
|
||||
activity_three = Activity.get_by_id(activity_three.id)
|
||||
|
||||
activities =
|
||||
ActivityPub.fetch_activities([], %{"muting_user" => user, "skip_preload" => true})
|
||||
|
|
@ -559,7 +559,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
{:ok, _, _, object} = ActivityPub.unlike(user, object)
|
||||
assert object.data["like_count"] == 0
|
||||
|
||||
assert Repo.get(Activity, like_activity.id) == nil
|
||||
assert Activity.get_by_id(like_activity.id) == nil
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -610,7 +610,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
assert unannounce_activity.data["actor"] == user.ap_id
|
||||
assert unannounce_activity.data["context"] == announce_activity.data["context"]
|
||||
|
||||
assert Repo.get(Activity, announce_activity.id) == nil
|
||||
assert Activity.get_by_id(announce_activity.id) == nil
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -749,7 +749,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
assert delete.data["actor"] == note.data["actor"]
|
||||
assert delete.data["object"] == note.data["object"]["id"]
|
||||
|
||||
assert Repo.get(Activity, delete.id) != nil
|
||||
assert Activity.get_by_id(delete.id) != nil
|
||||
|
||||
assert Repo.get(Object, object.id).data["type"] == "Tombstone"
|
||||
end
|
||||
|
|
@ -758,23 +758,23 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
user = insert(:user, info: %{note_count: 10})
|
||||
|
||||
{:ok, a1} =
|
||||
CommonAPI.post(Repo.get(User, user.id), %{"status" => "yeah", "visibility" => "public"})
|
||||
CommonAPI.post(User.get_by_id(user.id), %{"status" => "yeah", "visibility" => "public"})
|
||||
|
||||
{:ok, a2} =
|
||||
CommonAPI.post(Repo.get(User, user.id), %{"status" => "yeah", "visibility" => "unlisted"})
|
||||
CommonAPI.post(User.get_by_id(user.id), %{"status" => "yeah", "visibility" => "unlisted"})
|
||||
|
||||
{:ok, a3} =
|
||||
CommonAPI.post(Repo.get(User, user.id), %{"status" => "yeah", "visibility" => "private"})
|
||||
CommonAPI.post(User.get_by_id(user.id), %{"status" => "yeah", "visibility" => "private"})
|
||||
|
||||
{:ok, a4} =
|
||||
CommonAPI.post(Repo.get(User, user.id), %{"status" => "yeah", "visibility" => "direct"})
|
||||
CommonAPI.post(User.get_by_id(user.id), %{"status" => "yeah", "visibility" => "direct"})
|
||||
|
||||
{:ok, _} = a1.data["object"]["id"] |> Object.get_by_ap_id() |> ActivityPub.delete()
|
||||
{:ok, _} = a2.data["object"]["id"] |> Object.get_by_ap_id() |> ActivityPub.delete()
|
||||
{:ok, _} = a3.data["object"]["id"] |> Object.get_by_ap_id() |> ActivityPub.delete()
|
||||
{:ok, _} = a4.data["object"]["id"] |> Object.get_by_ap_id() |> ActivityPub.delete()
|
||||
|
||||
user = Repo.get(User, user.id)
|
||||
user = User.get_by_id(user.id)
|
||||
assert user.info.note_count == 10
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -461,7 +461,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
|
||||
{:ok, %Activity{local: false}} = Transmogrifier.handle_incoming(data)
|
||||
|
||||
refute Repo.get(Activity, activity.id)
|
||||
refute Activity.get_by_id(activity.id)
|
||||
end
|
||||
|
||||
test "it fails for incoming deletes with spoofed origin" do
|
||||
|
|
@ -481,7 +481,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
|
||||
:error = Transmogrifier.handle_incoming(data)
|
||||
|
||||
assert Repo.get(Activity, activity.id)
|
||||
assert Activity.get_by_id(activity.id)
|
||||
end
|
||||
|
||||
test "it works for incoming unannounces with an existing notice" do
|
||||
|
|
@ -639,7 +639,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
|
||||
assert activity.data["object"] == follow_activity.data["id"]
|
||||
|
||||
follower = Repo.get(User, follower.id)
|
||||
follower = User.get_by_id(follower.id)
|
||||
|
||||
assert User.following?(follower, followed) == true
|
||||
end
|
||||
|
|
@ -661,7 +661,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
{:ok, activity} = Transmogrifier.handle_incoming(accept_data)
|
||||
assert activity.data["object"] == follow_activity.data["id"]
|
||||
|
||||
follower = Repo.get(User, follower.id)
|
||||
follower = User.get_by_id(follower.id)
|
||||
|
||||
assert User.following?(follower, followed) == true
|
||||
end
|
||||
|
|
@ -681,7 +681,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
{:ok, activity} = Transmogrifier.handle_incoming(accept_data)
|
||||
assert activity.data["object"] == follow_activity.data["id"]
|
||||
|
||||
follower = Repo.get(User, follower.id)
|
||||
follower = User.get_by_id(follower.id)
|
||||
|
||||
assert User.following?(follower, followed) == true
|
||||
end
|
||||
|
|
@ -700,7 +700,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
|
||||
:error = Transmogrifier.handle_incoming(accept_data)
|
||||
|
||||
follower = Repo.get(User, follower.id)
|
||||
follower = User.get_by_id(follower.id)
|
||||
|
||||
refute User.following?(follower, followed) == true
|
||||
end
|
||||
|
|
@ -719,7 +719,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
|
||||
:error = Transmogrifier.handle_incoming(accept_data)
|
||||
|
||||
follower = Repo.get(User, follower.id)
|
||||
follower = User.get_by_id(follower.id)
|
||||
|
||||
refute User.following?(follower, followed) == true
|
||||
end
|
||||
|
|
@ -744,7 +744,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
{:ok, activity} = Transmogrifier.handle_incoming(reject_data)
|
||||
refute activity.local
|
||||
|
||||
follower = Repo.get(User, follower.id)
|
||||
follower = User.get_by_id(follower.id)
|
||||
|
||||
assert User.following?(follower, followed) == false
|
||||
end
|
||||
|
|
@ -766,7 +766,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
|
||||
{:ok, %Activity{data: _}} = Transmogrifier.handle_incoming(reject_data)
|
||||
|
||||
follower = Repo.get(User, follower.id)
|
||||
follower = User.get_by_id(follower.id)
|
||||
|
||||
assert User.following?(follower, followed) == false
|
||||
end
|
||||
|
|
@ -1020,7 +1020,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
{:ok, unrelated_activity} = CommonAPI.post(user_two, %{"status" => "test"})
|
||||
assert "http://localhost:4001/users/rye@niu.moe/followers" in activity.recipients
|
||||
|
||||
user = Repo.get(User, user.id)
|
||||
user = User.get_by_id(user.id)
|
||||
assert user.info.note_count == 1
|
||||
|
||||
{:ok, user} = Transmogrifier.upgrade_user_from_ap_id("https://niu.moe/users/rye")
|
||||
|
|
@ -1031,10 +1031,10 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
# Wait for the background task
|
||||
:timer.sleep(1000)
|
||||
|
||||
user = Repo.get(User, user.id)
|
||||
user = User.get_by_id(user.id)
|
||||
assert user.info.note_count == 1
|
||||
|
||||
activity = Repo.get(Activity, activity.id)
|
||||
activity = Activity.get_by_id(activity.id)
|
||||
assert user.follower_address in activity.recipients
|
||||
|
||||
assert %{
|
||||
|
|
@ -1057,10 +1057,10 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
|
||||
refute "..." in activity.recipients
|
||||
|
||||
unrelated_activity = Repo.get(Activity, unrelated_activity.id)
|
||||
unrelated_activity = Activity.get_by_id(unrelated_activity.id)
|
||||
refute user.follower_address in unrelated_activity.recipients
|
||||
|
||||
user_two = Repo.get(User, user_two.id)
|
||||
user_two = User.get_by_id(user_two.id)
|
||||
assert user.follower_address in user_two.following
|
||||
refute "..." in user_two.following
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
||||
use Pleroma.Web.ConnCase
|
||||
|
||||
alias Pleroma.Repo
|
||||
alias Pleroma.User
|
||||
import Pleroma.Factory
|
||||
|
||||
|
|
@ -101,13 +100,13 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
user2: user2
|
||||
} do
|
||||
assert json_response(conn, :no_content)
|
||||
assert Repo.get(User, user1.id).tags == ["x", "foo", "bar"]
|
||||
assert Repo.get(User, user2.id).tags == ["y", "foo", "bar"]
|
||||
assert User.get_by_id(user1.id).tags == ["x", "foo", "bar"]
|
||||
assert User.get_by_id(user2.id).tags == ["y", "foo", "bar"]
|
||||
end
|
||||
|
||||
test "it does not modify tags of not specified users", %{conn: conn, user3: user3} do
|
||||
assert json_response(conn, :no_content)
|
||||
assert Repo.get(User, user3.id).tags == ["unchanged"]
|
||||
assert User.get_by_id(user3.id).tags == ["unchanged"]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -137,13 +136,13 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
user2: user2
|
||||
} do
|
||||
assert json_response(conn, :no_content)
|
||||
assert Repo.get(User, user1.id).tags == []
|
||||
assert Repo.get(User, user2.id).tags == ["y"]
|
||||
assert User.get_by_id(user1.id).tags == []
|
||||
assert User.get_by_id(user2.id).tags == ["y"]
|
||||
end
|
||||
|
||||
test "it does not modify tags of not specified users", %{conn: conn, user3: user3} do
|
||||
assert json_response(conn, :no_content)
|
||||
assert Repo.get(User, user3.id).tags == ["unchanged"]
|
||||
assert User.get_by_id(user3.id).tags == ["unchanged"]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -213,7 +212,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
conn
|
||||
|> put("/api/pleroma/admin/activation_status/#{user.nickname}", %{status: false})
|
||||
|
||||
user = Repo.get(User, user.id)
|
||||
user = User.get_by_id(user.id)
|
||||
assert user.info.deactivated == true
|
||||
assert json_response(conn, :no_content)
|
||||
end
|
||||
|
|
@ -225,7 +224,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
conn
|
||||
|> put("/api/pleroma/admin/activation_status/#{user.nickname}", %{status: true})
|
||||
|
||||
user = Repo.get(User, user.id)
|
||||
user = User.get_by_id(user.id)
|
||||
assert user.info.deactivated == false
|
||||
assert json_response(conn, :no_content)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
assert %{"content" => "cofe", "id" => id, "spoiler_text" => "2hu", "sensitive" => false} =
|
||||
json_response(conn_one, 200)
|
||||
|
||||
assert Repo.get(Activity, id)
|
||||
assert Activity.get_by_id(id)
|
||||
|
||||
conn_two =
|
||||
conn
|
||||
|
|
@ -140,7 +140,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
|> post("/api/v1/statuses", %{"status" => "cofe", "sensitive" => true})
|
||||
|
||||
assert %{"content" => "cofe", "id" => id, "sensitive" => true} = json_response(conn, 200)
|
||||
assert Repo.get(Activity, id)
|
||||
assert Activity.get_by_id(id)
|
||||
end
|
||||
|
||||
test "posting a status with OGP link preview", %{conn: conn} do
|
||||
|
|
@ -155,7 +155,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
})
|
||||
|
||||
assert %{"id" => id, "card" => %{"title" => "The Rock"}} = json_response(conn, 200)
|
||||
assert Repo.get(Activity, id)
|
||||
assert Activity.get_by_id(id)
|
||||
Pleroma.Config.put([:rich_media, :enabled], false)
|
||||
end
|
||||
|
||||
|
|
@ -170,7 +170,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
|> post("api/v1/statuses", %{"status" => content, "visibility" => "direct"})
|
||||
|
||||
assert %{"id" => id, "visibility" => "direct"} = json_response(conn, 200)
|
||||
assert activity = Repo.get(Activity, id)
|
||||
assert activity = Activity.get_by_id(id)
|
||||
assert activity.recipients == [user2.ap_id, user1.ap_id]
|
||||
assert activity.data["to"] == [user2.ap_id]
|
||||
assert activity.data["cc"] == []
|
||||
|
|
@ -289,7 +289,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
|
||||
assert %{"content" => "xD", "id" => id} = json_response(conn, 200)
|
||||
|
||||
activity = Repo.get(Activity, id)
|
||||
activity = Activity.get_by_id(id)
|
||||
|
||||
assert activity.data["context"] == replied_to.data["context"]
|
||||
assert activity.data["object"]["inReplyToStatusId"] == replied_to.id
|
||||
|
|
@ -305,7 +305,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
|
||||
assert %{"content" => "xD", "id" => id} = json_response(conn, 200)
|
||||
|
||||
activity = Repo.get(Activity, id)
|
||||
activity = Activity.get_by_id(id)
|
||||
|
||||
assert activity
|
||||
end
|
||||
|
|
@ -404,7 +404,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
|
||||
assert %{} = json_response(conn, 200)
|
||||
|
||||
refute Repo.get(Activity, activity.id)
|
||||
refute Activity.get_by_id(activity.id)
|
||||
end
|
||||
|
||||
test "when you didn't create it", %{conn: conn} do
|
||||
|
|
@ -418,7 +418,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
|
||||
assert %{"error" => _} = json_response(conn, 403)
|
||||
|
||||
assert Repo.get(Activity, activity.id) == activity
|
||||
assert Activity.get_by_id(activity.id) == activity
|
||||
end
|
||||
|
||||
test "when you're an admin or moderator", %{conn: conn} do
|
||||
|
|
@ -441,8 +441,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
|
||||
assert %{} = json_response(res_conn, 200)
|
||||
|
||||
refute Repo.get(Activity, activity1.id)
|
||||
refute Repo.get(Activity, activity2.id)
|
||||
refute Activity.get_by_id(activity1.id)
|
||||
refute Activity.get_by_id(activity2.id)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -1112,8 +1112,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
|
||||
{:ok, _activity} = ActivityPub.follow(other_user, user)
|
||||
|
||||
user = Repo.get(User, user.id)
|
||||
other_user = Repo.get(User, other_user.id)
|
||||
user = User.get_by_id(user.id)
|
||||
other_user = User.get_by_id(other_user.id)
|
||||
|
||||
assert User.following?(other_user, user) == false
|
||||
|
||||
|
|
@ -1132,8 +1132,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
|
||||
{:ok, _activity} = ActivityPub.follow(other_user, user)
|
||||
|
||||
user = Repo.get(User, user.id)
|
||||
other_user = Repo.get(User, other_user.id)
|
||||
user = User.get_by_id(user.id)
|
||||
other_user = User.get_by_id(other_user.id)
|
||||
|
||||
assert User.following?(other_user, user) == false
|
||||
|
||||
|
|
@ -1145,8 +1145,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
assert relationship = json_response(conn, 200)
|
||||
assert to_string(other_user.id) == relationship["id"]
|
||||
|
||||
user = Repo.get(User, user.id)
|
||||
other_user = Repo.get(User, other_user.id)
|
||||
user = User.get_by_id(user.id)
|
||||
other_user = User.get_by_id(other_user.id)
|
||||
|
||||
assert User.following?(other_user, user) == true
|
||||
end
|
||||
|
|
@ -1169,7 +1169,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
|
||||
{:ok, _activity} = ActivityPub.follow(other_user, user)
|
||||
|
||||
user = Repo.get(User, user.id)
|
||||
user = User.get_by_id(user.id)
|
||||
|
||||
conn =
|
||||
build_conn()
|
||||
|
|
@ -1179,8 +1179,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
assert relationship = json_response(conn, 200)
|
||||
assert to_string(other_user.id) == relationship["id"]
|
||||
|
||||
user = Repo.get(User, user.id)
|
||||
other_user = Repo.get(User, other_user.id)
|
||||
user = User.get_by_id(user.id)
|
||||
other_user = User.get_by_id(other_user.id)
|
||||
|
||||
assert User.following?(other_user, user) == false
|
||||
end
|
||||
|
|
@ -1465,7 +1465,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
|
||||
assert %{"id" => _id, "following" => true} = json_response(conn, 200)
|
||||
|
||||
user = Repo.get(User, user.id)
|
||||
user = User.get_by_id(user.id)
|
||||
|
||||
conn =
|
||||
build_conn()
|
||||
|
|
@ -1474,7 +1474,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
|
||||
assert %{"id" => _id, "following" => false} = json_response(conn, 200)
|
||||
|
||||
user = Repo.get(User, user.id)
|
||||
user = User.get_by_id(user.id)
|
||||
|
||||
conn =
|
||||
build_conn()
|
||||
|
|
@ -1496,7 +1496,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
|
||||
assert %{"id" => _id, "muting" => true} = json_response(conn, 200)
|
||||
|
||||
user = Repo.get(User, user.id)
|
||||
user = User.get_by_id(user.id)
|
||||
|
||||
conn =
|
||||
build_conn()
|
||||
|
|
@ -1532,7 +1532,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
|
||||
assert %{"id" => _id, "blocking" => true} = json_response(conn, 200)
|
||||
|
||||
user = Repo.get(User, user.id)
|
||||
user = User.get_by_id(user.id)
|
||||
|
||||
conn =
|
||||
build_conn()
|
||||
|
|
@ -1889,7 +1889,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
{:ok, _} = TwitterAPI.create_status(user, %{"status" => "cofe"})
|
||||
|
||||
# Stats should count users with missing or nil `info.deactivated` value
|
||||
user = Repo.get(User, user.id)
|
||||
user = User.get_by_id(user.id)
|
||||
info_change = Changeset.change(user.info, %{deactivated: nil})
|
||||
|
||||
{:ok, _user} =
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do
|
|||
mentioned_user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "hey @#{mentioned_user.nickname}"})
|
||||
{:ok, [notification]} = Notification.create_notifications(activity)
|
||||
user = Repo.get(User, user.id)
|
||||
user = User.get_by_id(user.id)
|
||||
|
||||
expected = %{
|
||||
id: to_string(notification.id),
|
||||
|
|
@ -44,7 +44,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do
|
|||
{:ok, create_activity} = CommonAPI.post(user, %{"status" => "hey"})
|
||||
{:ok, favorite_activity, _object} = CommonAPI.favorite(create_activity.id, another_user)
|
||||
{:ok, [notification]} = Notification.create_notifications(favorite_activity)
|
||||
create_activity = Repo.get(Activity, create_activity.id)
|
||||
create_activity = Activity.get_by_id(create_activity.id)
|
||||
|
||||
expected = %{
|
||||
id: to_string(notification.id),
|
||||
|
|
@ -66,7 +66,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do
|
|||
{:ok, create_activity} = CommonAPI.post(user, %{"status" => "hey"})
|
||||
{:ok, reblog_activity, _object} = CommonAPI.repeat(create_activity.id, another_user)
|
||||
{:ok, [notification]} = Notification.create_notifications(reblog_activity)
|
||||
reblog_activity = Repo.get(Activity, create_activity.id)
|
||||
reblog_activity = Activity.get_by_id(create_activity.id)
|
||||
|
||||
expected = %{
|
||||
id: to_string(notification.id),
|
||||
|
|
|
|||
|
|
@ -116,10 +116,10 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do
|
|||
|
||||
{:ok, announce, _object} = ActivityPub.announce(user, object)
|
||||
|
||||
announce = Repo.get(Activity, announce.id)
|
||||
announce = Activity.get_by_id(announce.id)
|
||||
|
||||
note_user = User.get_cached_by_ap_id(note.data["actor"])
|
||||
note = Repo.get(Activity, note.id)
|
||||
note = Activity.get_by_id(note.id)
|
||||
|
||||
note_xml =
|
||||
ActivityRepresenter.to_simple_form(note, note_user, true)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ defmodule Pleroma.Web.OStatus.DeleteHandlingTest do
|
|||
|
||||
alias Pleroma.Activity
|
||||
alias Pleroma.Object
|
||||
alias Pleroma.Repo
|
||||
alias Pleroma.Web.OStatus
|
||||
|
||||
setup do
|
||||
|
|
@ -32,10 +31,10 @@ defmodule Pleroma.Web.OStatus.DeleteHandlingTest do
|
|||
|
||||
{:ok, [delete]} = OStatus.handle_incoming(incoming)
|
||||
|
||||
refute Repo.get(Activity, note.id)
|
||||
refute Repo.get(Activity, like.id)
|
||||
refute Activity.get_by_id(note.id)
|
||||
refute Activity.get_by_id(like.id)
|
||||
assert Object.get_by_ap_id(note.data["object"]["id"]).data["type"] == "Tombstone"
|
||||
assert Repo.get(Activity, second_note.id)
|
||||
assert Activity.get_by_id(second_note.id)
|
||||
assert Object.get_by_ap_id(second_note.data["object"]["id"])
|
||||
|
||||
assert delete.data["type"] == "Delete"
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ defmodule Pleroma.Web.OStatusTest do
|
|||
assert "https://pleroma.soykaf.com/users/lain" in activity.data["to"]
|
||||
refute activity.local
|
||||
|
||||
retweeted_activity = Repo.get(Activity, retweeted_activity.id)
|
||||
retweeted_activity = Activity.get_by_id(retweeted_activity.id)
|
||||
assert retweeted_activity.data["type"] == "Create"
|
||||
assert retweeted_activity.data["actor"] == "https://pleroma.soykaf.com/users/lain"
|
||||
refute retweeted_activity.local
|
||||
|
|
@ -181,7 +181,7 @@ defmodule Pleroma.Web.OStatusTest do
|
|||
assert user.ap_id in activity.data["to"]
|
||||
refute activity.local
|
||||
|
||||
retweeted_activity = Repo.get(Activity, retweeted_activity.id)
|
||||
retweeted_activity = Activity.get_by_id(retweeted_activity.id)
|
||||
assert note_activity.id == retweeted_activity.id
|
||||
assert retweeted_activity.data["type"] == "Create"
|
||||
assert retweeted_activity.data["actor"] == user.ap_id
|
||||
|
|
@ -344,7 +344,7 @@ defmodule Pleroma.Web.OStatusTest do
|
|||
|
||||
{:ok, user} = OStatus.find_or_make_user(uri)
|
||||
|
||||
user = Repo.get(Pleroma.User, user.id)
|
||||
user = Pleroma.User.get_by_id(user.id)
|
||||
assert user.name == "Constance Variable"
|
||||
assert user.nickname == "lambadalambda@social.heldscal.la"
|
||||
assert user.local == false
|
||||
|
|
|
|||
|
|
@ -719,7 +719,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
|> with_credentials(current_user.nickname, "test")
|
||||
|> post("/api/friendships/create.json", %{user_id: followed.id})
|
||||
|
||||
current_user = Repo.get(User, current_user.id)
|
||||
current_user = User.get_by_id(current_user.id)
|
||||
assert User.ap_followers(followed) in current_user.following
|
||||
|
||||
assert json_response(conn, 200) ==
|
||||
|
|
@ -734,8 +734,8 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
|> with_credentials(current_user.nickname, "test")
|
||||
|> post("/api/friendships/create.json", %{user_id: followed.id})
|
||||
|
||||
current_user = Repo.get(User, current_user.id)
|
||||
followed = Repo.get(User, followed.id)
|
||||
current_user = User.get_by_id(current_user.id)
|
||||
followed = User.get_by_id(followed.id)
|
||||
|
||||
refute User.ap_followers(followed) in current_user.following
|
||||
|
||||
|
|
@ -764,7 +764,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
|> with_credentials(current_user.nickname, "test")
|
||||
|> post("/api/friendships/destroy.json", %{user_id: followed.id})
|
||||
|
||||
current_user = Repo.get(User, current_user.id)
|
||||
current_user = User.get_by_id(current_user.id)
|
||||
assert current_user.following == [current_user.ap_id]
|
||||
|
||||
assert json_response(conn, 200) ==
|
||||
|
|
@ -788,7 +788,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
|> with_credentials(current_user.nickname, "test")
|
||||
|> post("/api/blocks/create.json", %{user_id: blocked.id})
|
||||
|
||||
current_user = Repo.get(User, current_user.id)
|
||||
current_user = User.get_by_id(current_user.id)
|
||||
assert User.blocks?(current_user, blocked)
|
||||
|
||||
assert json_response(conn, 200) ==
|
||||
|
|
@ -815,7 +815,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
|> with_credentials(current_user.nickname, "test")
|
||||
|> post("/api/blocks/destroy.json", %{user_id: blocked.id})
|
||||
|
||||
current_user = Repo.get(User, current_user.id)
|
||||
current_user = User.get_by_id(current_user.id)
|
||||
assert current_user.info.blocks == []
|
||||
|
||||
assert json_response(conn, 200) ==
|
||||
|
|
@ -846,7 +846,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
|> with_credentials(current_user.nickname, "test")
|
||||
|> post("/api/qvitter/update_avatar.json", %{img: avatar_image})
|
||||
|
||||
current_user = Repo.get(User, current_user.id)
|
||||
current_user = User.get_by_id(current_user.id)
|
||||
assert is_map(current_user.avatar)
|
||||
|
||||
assert json_response(conn, 200) ==
|
||||
|
|
@ -954,7 +954,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
|> with_credentials(current_user.nickname, "test")
|
||||
|> post(request_path)
|
||||
|
||||
activity = Repo.get(Activity, note_activity.id)
|
||||
activity = Activity.get_by_id(note_activity.id)
|
||||
activity_user = Repo.get_by(User, ap_id: note_activity.data["actor"])
|
||||
|
||||
assert json_response(response, 200) ==
|
||||
|
|
@ -992,7 +992,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
|> with_credentials(current_user.nickname, "test")
|
||||
|> post(request_path)
|
||||
|
||||
activity = Repo.get(Activity, note_activity.id)
|
||||
activity = Activity.get_by_id(note_activity.id)
|
||||
activity_user = Repo.get_by(User, ap_id: note_activity.data["actor"])
|
||||
|
||||
assert json_response(response, 200) ==
|
||||
|
|
@ -1109,7 +1109,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
test "it confirms the user account", %{conn: conn, user: user} do
|
||||
get(conn, "/api/account/confirm_email/#{user.id}/#{user.info.confirmation_token}")
|
||||
|
||||
user = Repo.get(User, user.id)
|
||||
user = User.get_by_id(user.id)
|
||||
|
||||
refute user.info.confirmation_pending
|
||||
refute user.info.confirmation_token
|
||||
|
|
@ -1727,7 +1727,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
})
|
||||
|
||||
assert json_response(conn, 200) == %{"status" => "success"}
|
||||
fetched_user = Repo.get(User, current_user.id)
|
||||
fetched_user = User.get_by_id(current_user.id)
|
||||
assert Pbkdf2.checkpw("newpass", fetched_user.password_hash) == true
|
||||
end
|
||||
end
|
||||
|
|
@ -1768,8 +1768,8 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
|
||||
{:ok, _activity} = ActivityPub.follow(other_user, user)
|
||||
|
||||
user = Repo.get(User, user.id)
|
||||
other_user = Repo.get(User, other_user.id)
|
||||
user = User.get_by_id(user.id)
|
||||
other_user = User.get_by_id(other_user.id)
|
||||
|
||||
assert User.following?(other_user, user) == false
|
||||
|
||||
|
|
@ -1808,8 +1808,8 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
|
||||
{:ok, _activity} = ActivityPub.follow(other_user, user)
|
||||
|
||||
user = Repo.get(User, user.id)
|
||||
other_user = Repo.get(User, other_user.id)
|
||||
user = User.get_by_id(user.id)
|
||||
other_user = User.get_by_id(other_user.id)
|
||||
|
||||
assert User.following?(other_user, user) == false
|
||||
|
||||
|
|
@ -1831,8 +1831,8 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|
|||
|
||||
{:ok, _activity} = ActivityPub.follow(other_user, user)
|
||||
|
||||
user = Repo.get(User, user.id)
|
||||
other_user = Repo.get(User, other_user.id)
|
||||
user = User.get_by_id(user.id)
|
||||
other_user = User.get_by_id(other_user.id)
|
||||
|
||||
assert User.following?(other_user, user) == false
|
||||
|
||||
|
|
|
|||
|
|
@ -281,7 +281,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do
|
|||
|
||||
convo_id = Utils.context_to_conversation_id(activity.data["object"]["context"])
|
||||
|
||||
activity = Repo.get(Activity, activity.id)
|
||||
activity = Activity.get_by_id(activity.id)
|
||||
|
||||
result = ActivityView.render("activity.json", activity: announce)
|
||||
|
||||
|
|
|
|||
|
|
@ -292,7 +292,7 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
|
|||
}
|
||||
}
|
||||
|
||||
blocker = Repo.get(User, blocker.id)
|
||||
blocker = User.get_by_id(blocker.id)
|
||||
assert represented == UserView.render("show.json", %{user: user, for: blocker})
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue