X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;ds=inline;f=test%2Flist_test.exs;h=e7b23915b073312ddd858bc231fd9af75c7b3a4e;hb=7df13e6f3a654515f143dccf94a2c66675105a35;hp=0e72b66604c212e87957f873fd23b4f04a08dfa8;hpb=a7a8f3bc2c3bb748f060812751a88873401354dd;p=akkoma
diff --git a/test/list_test.exs b/test/list_test.exs
index 0e72b6660..e7b23915b 100644
--- a/test/list_test.exs
+++ b/test/list_test.exs
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2018 Pleroma Authors
+# Copyright © 2017-2019 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.ListTest do
@@ -15,6 +15,13 @@ defmodule Pleroma.ListTest do
assert title == "title"
end
+ test "validates title" do
+ user = insert(:user)
+
+ assert {:error, changeset} = Pleroma.List.create("", user)
+ assert changeset.errors == [title: {"can't be blank", [validation: :required]}]
+ end
+
test "getting a list not belonging to the user" do
user = insert(:user)
other_user = insert(:user)
@@ -106,30 +113,18 @@ defmodule Pleroma.ListTest do
{:ok, not_owned_list} = Pleroma.List.follow(not_owned_list, member_1)
{:ok, not_owned_list} = Pleroma.List.follow(not_owned_list, member_2)
- lists_1 = Pleroma.List.get_lists_account_belongs(owner, member_1.id)
+ lists_1 = Pleroma.List.get_lists_account_belongs(owner, member_1)
assert owned_list in lists_1
refute not_owned_list in lists_1
- lists_2 = Pleroma.List.get_lists_account_belongs(owner, member_2.id)
+ lists_2 = Pleroma.List.get_lists_account_belongs(owner, member_2)
assert owned_list in lists_2
refute not_owned_list in lists_2
end
- test "get ap_id by user nickname and list id" do
- nickname = "foo"
- list_id = 42
-
- expected = Pleroma.Web.Endpoint.url() <> "/users/#{nickname}/lists/#{list_id}"
-
- assert Pleroma.List.ap_id(%Pleroma.User{nickname: nickname}, list_id) == expected
- assert Pleroma.List.ap_id({nickname, list_id}) == expected
- end
-
test "get by ap_id" do
user = insert(:user)
{:ok, list} = Pleroma.List.create("foo", user)
- ap_id = Pleroma.List.ap_id(user, list.id)
-
- assert Pleroma.List.get_by_ap_id(ap_id) == list
+ assert Pleroma.List.get_by_ap_id(list.ap_id) == list
end
test "memberships" do
@@ -138,8 +133,17 @@ defmodule Pleroma.ListTest do
{:ok, list} = Pleroma.List.create("foo", user)
{:ok, list} = Pleroma.List.follow(list, member)
- list_ap_id = Pleroma.List.ap_id(user, list.id)
+ assert Pleroma.List.memberships(member) == [list.ap_id]
+ end
+
+ test "member?" do
+ user = insert(:user)
+ member = insert(:user)
+
+ {:ok, list} = Pleroma.List.create("foo", user)
+ {:ok, list} = Pleroma.List.follow(list, member)
- assert Pleroma.List.memberships(member) == [list_ap_id]
+ assert Pleroma.List.member?(list, member)
+ refute Pleroma.List.member?(list, user)
end
end