aboutsummaryrefslogtreecommitdiff
path: root/test/web/mastodon_api
diff options
context:
space:
mode:
authorRoger Braun <rbraun@Bobble.local>2017-09-13 15:55:10 +0200
committerRoger Braun <rbraun@Bobble.local>2017-09-13 15:55:10 +0200
commit49929321c761cf389d42ca52d88dc8ec09a375cc (patch)
tree2b1617202f4475a48d9d46a9773ea262d96b5ce4 /test/web/mastodon_api
parentf03524805fdc95b9681f59a68a1edb2885f2e7ba (diff)
downloadpleroma-49929321c761cf389d42ca52d88dc8ec09a375cc.tar.gz
Add relationships to masto api.
Diffstat (limited to 'test/web/mastodon_api')
-rw-r--r--test/web/mastodon_api/account_view_test.exs20
-rw-r--r--test/web/mastodon_api/mastodon_api_controller_test.exs17
2 files changed, 37 insertions, 0 deletions
diff --git a/test/web/mastodon_api/account_view_test.exs b/test/web/mastodon_api/account_view_test.exs
index 0106fbcc0..259258281 100644
--- a/test/web/mastodon_api/account_view_test.exs
+++ b/test/web/mastodon_api/account_view_test.exs
@@ -2,6 +2,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
use Pleroma.DataCase
import Pleroma.Factory
alias Pleroma.Web.MastodonAPI.AccountView
+ alias Pleroma.User
test "Represent a user account" do
user = insert(:user, %{info: %{"note_count" => 5, "follower_count" => 3}, nickname: "shp@shitposter.club"})
@@ -39,4 +40,23 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
assert expected == AccountView.render("mention.json", %{user: user})
end
+
+ test "represent a relationship" do
+ user = insert(:user)
+ other_user = insert(:user)
+
+ {:ok, user} = User.follow(user, other_user)
+
+ expected = %{
+ id: other_user.id,
+ following: false,
+ followed_by: true,
+ blocking: false,
+ muting: false,
+ requested: false,
+ domain_blocking: false
+ }
+
+ assert expected == AccountView.render("relationship.json", %{user: user, target: other_user})
+ end
end
diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs
index e87430d3f..52415bb50 100644
--- a/test/web/mastodon_api/mastodon_api_controller_test.exs
+++ b/test/web/mastodon_api/mastodon_api_controller_test.exs
@@ -181,4 +181,21 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
assert id == note_two.id
end
end
+
+ describe "user relationships" do
+ test "returns the relationships for the current user", %{conn: conn} do
+ user = insert(:user)
+ other_user = insert(:user)
+
+ {:ok, user} = User.follow(user, other_user)
+
+ conn = conn
+ |> assign(:user, user)
+ |> get("/api/v1/accounts/relationships", %{"id" => [other_user.id]})
+
+ assert [relationship] = json_response(conn, 200)
+
+ assert other_user.id == relationship["id"]
+ end
+ end
end