Merge branch 'feature/807-bookmark-endpoint-extension' into 'develop'
Feature/807 bookmark endpoint extension Closes #807 See merge request pleroma/pleroma!1059
This commit is contained in:
commit
4de5fef1f8
10 changed files with 182 additions and 56 deletions
37
test/bookmark_test.exs
Normal file
37
test/bookmark_test.exs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
defmodule Pleroma.BookmarkTest do
|
||||
use Pleroma.DataCase
|
||||
import Pleroma.Factory
|
||||
alias Pleroma.Bookmark
|
||||
alias Pleroma.Web.CommonAPI
|
||||
|
||||
describe "create/2" do
|
||||
test "with valid params" do
|
||||
user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "Some cool information"})
|
||||
{:ok, bookmark} = Bookmark.create(user.id, activity.id)
|
||||
assert bookmark.user_id == user.id
|
||||
assert bookmark.activity_id == activity.id
|
||||
end
|
||||
|
||||
test "with invalid params" do
|
||||
{:error, changeset} = Bookmark.create(nil, "")
|
||||
refute changeset.valid?
|
||||
|
||||
assert changeset.errors == [
|
||||
user_id: {"can't be blank", [validation: :required]},
|
||||
activity_id: {"can't be blank", [validation: :required]}
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
describe "destroy/2" do
|
||||
test "with valid params" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "Some cool information"})
|
||||
{:ok, _bookmark} = Bookmark.create(user.id, activity.id)
|
||||
|
||||
{:ok, _deleted_bookmark} = Bookmark.destroy(user.id, activity.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1125,33 +1125,6 @@ defmodule Pleroma.UserTest do
|
|||
end
|
||||
end
|
||||
|
||||
test "bookmarks" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, activity1} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "heweoo!"
|
||||
})
|
||||
|
||||
id1 = Object.normalize(activity1).data["id"]
|
||||
|
||||
{:ok, activity2} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "heweoo!"
|
||||
})
|
||||
|
||||
id2 = Object.normalize(activity2).data["id"]
|
||||
|
||||
assert {:ok, user_state1} = User.bookmark(user, id1)
|
||||
assert user_state1.bookmarks == [id1]
|
||||
|
||||
assert {:ok, user_state2} = User.unbookmark(user, id1)
|
||||
assert user_state2.bookmarks == []
|
||||
|
||||
assert {:ok, user_state3} = User.bookmark(user, id2)
|
||||
assert user_state3.bookmarks == [id2]
|
||||
end
|
||||
|
||||
test "follower count is updated when a follower is blocked" do
|
||||
user = insert(:user)
|
||||
follower = insert(:user)
|
||||
|
|
|
|||
|
|
@ -1022,7 +1022,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
user2 = insert(:user)
|
||||
user3 = insert(:user)
|
||||
CommonAPI.favorite(activity.id, user2)
|
||||
{:ok, user2} = User.bookmark(user2, activity.data["object"]["id"])
|
||||
{:ok, _bookmark} = Pleroma.Bookmark.create(user2.id, activity.id)
|
||||
{:ok, reblog_activity1, _object} = CommonAPI.repeat(activity.id, user1)
|
||||
{:ok, _, _object} = CommonAPI.repeat(activity.id, user2)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue