update test

This commit is contained in:
Maksim Pechnikov 2019-12-22 21:17:19 +03:00
parent 4c505bc615
commit bdd71669da
2 changed files with 27 additions and 22 deletions

View file

@ -6,5 +6,5 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowView do
use Pleroma.Web, :view
import Phoenix.HTML.Form
defdelegate avatar_url(user), to: Pleroma.User.avatar_url
defdelegate avatar_url(user), to: Pleroma.User
end

View file

@ -21,19 +21,19 @@ defmodule Pleroma.Web.TwitterAPI.RemoteFollowControllerTest do
describe "GET /ostatus_subscribe - remote_follow/2" do
test "adds status to pleroma instance if the `acct` is a status", %{conn: conn} do
conn =
get(
conn,
"/ostatus_subscribe?acct=https://mastodon.social/users/emelie/statuses/101849165031453009"
)
assert redirected_to(conn) =~ "/notice/"
assert conn
|> get(
remote_follow_path(conn, :follow, %{
acct: "https://mastodon.social/users/emelie/statuses/101849165031453009"
})
)
|> redirected_to() =~ "/notice/"
end
test "show follow account page if the `acct` is a account link", %{conn: conn} do
response =
conn
|> get("/ostatus_subscribe?acct=https://mastodon.social/users/emelie")
|> get(remote_follow_path(conn, :follow, %{acct: "https://mastodon.social/users/emelie"}))
|> html_response(200)
assert response =~ "Log in to follow"
@ -45,7 +45,7 @@ test "show follow page if the `acct` is a account link", %{conn: conn} do
response =
conn
|> assign(:user, user)
|> get("/ostatus_subscribe?acct=https://mastodon.social/users/emelie")
|> get(remote_follow_path(conn, :follow, %{acct: "https://mastodon.social/users/emelie"}))
|> html_response(200)
assert response =~ "Remote follow"
@ -58,9 +58,14 @@ test "show follow page with error when user cannot fecth by `acct` link", %{conn
response =
conn
|> assign(:user, user)
|> get("/ostatus_subscribe?acct=https://mastodon.social/users/not_found")
|> get(
remote_follow_path(conn, :follow, %{
acct: "https://mastodon.social/users/not_found"
})
)
|> html_response(200)
assert html_response(response, 200) =~ "Error fetching user"
assert response =~ "Error fetching user"
end) =~ "Object has been deleted"
end
end
@ -73,7 +78,7 @@ test "follows user", %{conn: conn} do
response =
conn
|> assign(:user, user)
|> post("/ostatus_subscribe", %{"user" => %{"id" => user2.id}})
|> post(remote_follow_path(conn, :do_follow), %{"user" => %{"id" => user2.id}})
|> response(200)
assert response =~ "Account followed!"
@ -87,7 +92,7 @@ test "returns error when user is deactivated", %{conn: conn} do
response =
conn
|> assign(:user, user)
|> post("/ostatus_subscribe", %{"user" => %{"id" => user2.id}})
|> post(remote_follow_path(conn, :do_follow), %{"user" => %{"id" => user2.id}})
|> response(200)
assert response =~ "Error following account"
@ -103,7 +108,7 @@ test "returns error when user is blocked", %{conn: conn} do
response =
conn
|> assign(:user, user)
|> post("/ostatus_subscribe", %{"user" => %{"id" => user2.id}})
|> post(remote_follow_path(conn, :do_follow), %{"user" => %{"id" => user2.id}})
|> response(200)
assert response =~ "Error following account"
@ -115,7 +120,7 @@ test "returns error when followee not found", %{conn: conn} do
response =
conn
|> assign(:user, user)
|> post("/ostatus_subscribe", %{"user" => %{"id" => "jimm"}})
|> post(remote_follow_path(conn, :do_follow), %{"user" => %{"id" => "jimm"}})
|> response(200)
assert response =~ "Error following account"
@ -129,7 +134,7 @@ test "returns success result when user already in followers", %{conn: conn} do
response =
conn
|> assign(:user, refresh_record(user))
|> post("/ostatus_subscribe", %{"user" => %{"id" => user2.id}})
|> post(remote_follow_path(conn, :do_follow), %{"user" => %{"id" => user2.id}})
|> response(200)
assert response =~ "Account followed!"
@ -143,7 +148,7 @@ test "follows", %{conn: conn} do
response =
conn
|> post("/ostatus_subscribe", %{
|> post(remote_follow_path(conn, :do_follow), %{
"authorization" => %{"name" => user.nickname, "password" => "test", "id" => user2.id}
})
|> response(200)
@ -157,7 +162,7 @@ test "returns error when followee not found", %{conn: conn} do
response =
conn
|> post("/ostatus_subscribe", %{
|> post(remote_follow_path(conn, :do_follow), %{
"authorization" => %{"name" => user.nickname, "password" => "test", "id" => "jimm"}
})
|> response(200)
@ -170,7 +175,7 @@ test "returns error when login invalid", %{conn: conn} do
response =
conn
|> post("/ostatus_subscribe", %{
|> post(remote_follow_path(conn, :do_follow), %{
"authorization" => %{"name" => "jimm", "password" => "test", "id" => user.id}
})
|> response(200)
@ -184,7 +189,7 @@ test "returns error when password invalid", %{conn: conn} do
response =
conn
|> post("/ostatus_subscribe", %{
|> post(remote_follow_path(conn, :do_follow), %{
"authorization" => %{"name" => user.nickname, "password" => "42", "id" => user2.id}
})
|> response(200)
@ -200,7 +205,7 @@ test "returns error when user is blocked", %{conn: conn} do
response =
conn
|> post("/ostatus_subscribe", %{
|> post(remote_follow_path(conn, :do_follow), %{
"authorization" => %{"name" => user.nickname, "password" => "test", "id" => user2.id}
})
|> response(200)