assert id == to_string(other_user.id)
end
+ test "muting / unmuting a user", %{conn: conn} do
+ user = insert(:user)
+ other_user = insert(:user)
+
+ conn =
+ conn
+ |> assign(:user, user)
+ |> post("/api/v1/accounts/#{other_user.id}/mute")
+
+ assert %{"id" => _id, "muting" => true} = json_response(conn, 200)
+
+ user = Repo.get(User, user.id)
+
+ conn =
+ build_conn()
+ |> assign(:user, user)
+ |> post("/api/v1/accounts/#{other_user.id}/unmute")
+
+ assert %{"id" => _id, "muting" => false} = json_response(conn, 200)
+ end
+
+ test "getting a list of mutes", %{conn: conn} do
+ user = insert(:user)
+ other_user = insert(:user)
+
+ {:ok, user} = User.mute(user, other_user)
+
+ conn =
+ conn
+ |> assign(:user, user)
+ |> get("/api/v1/mutes")
+
+ other_user_id = to_string(other_user.id)
+ assert [%{"id" => ^other_user_id}] = json_response(conn, 200)
+ end
+
test "blocking / unblocking a user", %{conn: conn} do
user = insert(:user)
other_user = insert(:user)
assert "even.worse.site" in domain_blocks
end
- test "unimplemented mute endpoints" do
- user = insert(:user)
- other_user = insert(:user)
-
- ["mute", "unmute"]
- |> Enum.each(fn endpoint ->
- conn =
- build_conn()
- |> assign(:user, user)
- |> post("/api/v1/accounts/#{other_user.id}/#{endpoint}")
-
- assert %{"id" => id} = json_response(conn, 200)
- assert id == to_string(other_user.id)
- end)
- end
-
- test "unimplemented mutes, follow_requests, blocks, domain blocks" do
+ test "unimplemented follow_requests, blocks, domain blocks" do
user = insert(:user)
- ["blocks", "domain_blocks", "mutes", "follow_requests"]
+ ["blocks", "domain_blocks", "follow_requests"]
|> Enum.each(fn endpoint ->
conn =
build_conn()