1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.BookmarkTest do
9 alias Pleroma.Web.CommonAPI
11 describe "create/2" do
12 test "with valid params" do
14 {:ok, activity} = CommonAPI.post(user, %{"status" => "Some cool information"})
15 {:ok, bookmark} = Bookmark.create(user.id, activity.id)
16 assert bookmark.user_id == user.id
17 assert bookmark.activity_id == activity.id
20 test "with invalid params" do
21 {:error, changeset} = Bookmark.create(nil, "")
22 refute changeset.valid?
24 assert changeset.errors == [
25 user_id: {"can't be blank", [validation: :required]},
26 activity_id: {"can't be blank", [validation: :required]}
31 describe "destroy/2" do
32 test "with valid params" do
35 {:ok, activity} = CommonAPI.post(user, %{"status" => "Some cool information"})
36 {:ok, _bookmark} = Bookmark.create(user.id, activity.id)
38 {:ok, _deleted_bookmark} = Bookmark.destroy(user.id, activity.id)
43 test "gets a bookmark" do
47 CommonAPI.post(user, %{
49 "Scientists Discover The Secret Behind Tenshi Eating A Corndog Being So Cute – Science Daily"
52 {:ok, bookmark} = Bookmark.create(user.id, activity.id)
53 assert bookmark == Bookmark.get(user.id, activity.id)