Merge branch 'bugfix/rel_me_missing_mocks' into 'develop'
Implement missing mocks for rel=me See merge request pleroma/pleroma!1598
This commit is contained in:
commit
5e7098cf69
@ -971,6 +971,22 @@ def get("https://mstdn.jp/.well-known/webfinger?resource=acct:kpherox@mstdn.jp",
|
|||||||
}}
|
}}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get("http://example.com/rel_me/anchor", _, _, _) do
|
||||||
|
{:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/rel_me_anchor.html")}}
|
||||||
|
end
|
||||||
|
|
||||||
|
def get("http://example.com/rel_me/anchor_nofollow", _, _, _) do
|
||||||
|
{:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/rel_me_anchor_nofollow.html")}}
|
||||||
|
end
|
||||||
|
|
||||||
|
def get("http://example.com/rel_me/link", _, _, _) do
|
||||||
|
{:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/rel_me_link.html")}}
|
||||||
|
end
|
||||||
|
|
||||||
|
def get("http://example.com/rel_me/null", _, _, _) do
|
||||||
|
{:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/rel_me_null.html")}}
|
||||||
|
end
|
||||||
|
|
||||||
def get(url, query, body, headers) do
|
def get(url, query, body, headers) do
|
||||||
{:error,
|
{:error,
|
||||||
"Mock response not implemented for GET #{inspect(url)}, #{query}, #{inspect(body)}, #{
|
"Mock response not implemented for GET #{inspect(url)}, #{query}, #{inspect(body)}, #{
|
||||||
|
@ -1253,18 +1253,18 @@ test "preserves hosts in user links text" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "Adds rel=me on linkbacked urls" do
|
test "Adds rel=me on linkbacked urls" do
|
||||||
user = insert(:user, ap_id: "http://social.example.org/users/lain")
|
user = insert(:user, ap_id: "https://social.example.org/users/lain")
|
||||||
|
|
||||||
bio = "http://example.org/rel_me/null"
|
bio = "http://example.com/rel_me/null"
|
||||||
expected_text = "<a href=\"#{bio}\">#{bio}</a>"
|
expected_text = "<a href=\"#{bio}\">#{bio}</a>"
|
||||||
assert expected_text == User.parse_bio(bio, user)
|
assert expected_text == User.parse_bio(bio, user)
|
||||||
|
|
||||||
bio = "http://example.org/rel_me/link"
|
bio = "http://example.com/rel_me/link"
|
||||||
expected_text = "<a href=\"#{bio}\">#{bio}</a>"
|
expected_text = "<a href=\"#{bio}\" rel=\"me\">#{bio}</a>"
|
||||||
assert expected_text == User.parse_bio(bio, user)
|
assert expected_text == User.parse_bio(bio, user)
|
||||||
|
|
||||||
bio = "http://example.org/rel_me/anchor"
|
bio = "http://example.com/rel_me/anchor"
|
||||||
expected_text = "<a href=\"#{bio}\">#{bio}</a>"
|
expected_text = "<a href=\"#{bio}\" rel=\"me\">#{bio}</a>"
|
||||||
assert expected_text == User.parse_bio(bio, user)
|
assert expected_text == User.parse_bio(bio, user)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -5,33 +5,8 @@
|
|||||||
defmodule Pleroma.Web.RelMeTest do
|
defmodule Pleroma.Web.RelMeTest do
|
||||||
use ExUnit.Case, async: true
|
use ExUnit.Case, async: true
|
||||||
|
|
||||||
setup do
|
setup_all do
|
||||||
Tesla.Mock.mock(fn
|
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
||||||
%{
|
|
||||||
method: :get,
|
|
||||||
url: "http://example.com/rel_me/anchor"
|
|
||||||
} ->
|
|
||||||
%Tesla.Env{status: 200, body: File.read!("test/fixtures/rel_me_anchor.html")}
|
|
||||||
|
|
||||||
%{
|
|
||||||
method: :get,
|
|
||||||
url: "http://example.com/rel_me/anchor_nofollow"
|
|
||||||
} ->
|
|
||||||
%Tesla.Env{status: 200, body: File.read!("test/fixtures/rel_me_anchor_nofollow.html")}
|
|
||||||
|
|
||||||
%{
|
|
||||||
method: :get,
|
|
||||||
url: "http://example.com/rel_me/link"
|
|
||||||
} ->
|
|
||||||
%Tesla.Env{status: 200, body: File.read!("test/fixtures/rel_me_link.html")}
|
|
||||||
|
|
||||||
%{
|
|
||||||
method: :get,
|
|
||||||
url: "http://example.com/rel_me/null"
|
|
||||||
} ->
|
|
||||||
%Tesla.Env{status: 200, body: File.read!("test/fixtures/rel_me_null.html")}
|
|
||||||
end)
|
|
||||||
|
|
||||||
:ok
|
:ok
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user