2017-04-18 16:41:51 +00:00
|
|
|
defmodule Pleroma.Web.OStatus.OStatusControllerTest do
|
|
|
|
use Pleroma.Web.ConnCase
|
|
|
|
import Pleroma.Factory
|
|
|
|
alias Pleroma.User
|
2017-05-19 13:53:02 +00:00
|
|
|
alias Pleroma.Web.OStatus.ActivityRepresenter
|
2017-04-18 16:41:51 +00:00
|
|
|
|
|
|
|
test "gets a feed", %{conn: conn} do
|
|
|
|
note_activity = insert(:note_activity)
|
|
|
|
user = User.get_cached_by_ap_id(note_activity.data["actor"])
|
|
|
|
|
|
|
|
conn = conn
|
|
|
|
|> get("/users/#{user.nickname}/feed.atom")
|
|
|
|
|
|
|
|
assert response(conn, 200)
|
|
|
|
end
|
2017-05-03 07:54:17 +00:00
|
|
|
|
|
|
|
test "gets an object", %{conn: conn} do
|
|
|
|
note_activity = insert(:note_activity)
|
2017-05-19 13:53:02 +00:00
|
|
|
user = User.get_by_ap_id(note_activity.data["actor"])
|
2017-05-03 07:54:17 +00:00
|
|
|
[_, uuid] = hd Regex.scan(~r/.+\/([\w-]+)$/, note_activity.data["object"]["id"])
|
|
|
|
url = "/objects/#{uuid}"
|
|
|
|
|
|
|
|
conn = conn
|
|
|
|
|> get(url)
|
|
|
|
|
2017-05-19 13:53:02 +00:00
|
|
|
expected = ActivityRepresenter.to_simple_form(note_activity, user, true)
|
|
|
|
|> ActivityRepresenter.wrap_with_entry
|
|
|
|
|> :xmerl.export_simple(:xmerl_xml)
|
|
|
|
|> to_string
|
|
|
|
|
|
|
|
assert response(conn, 200) == expected
|
|
|
|
end
|
|
|
|
|
|
|
|
test "gets an activity", %{conn: conn} do
|
|
|
|
note_activity = insert(:note_activity)
|
|
|
|
[_, uuid] = hd Regex.scan(~r/.+\/([\w-]+)$/, note_activity.data["id"])
|
|
|
|
url = "/activities/#{uuid}"
|
|
|
|
|
|
|
|
conn = conn
|
|
|
|
|> get(url)
|
|
|
|
|
2017-05-03 07:54:17 +00:00
|
|
|
assert response(conn, 200)
|
|
|
|
end
|
2017-04-18 16:41:51 +00:00
|
|
|
end
|