Merge branch 'features/glitch-soc-frontend' into 'develop'
Features/glitch soc frontend See merge request pleroma/pleroma!192
This commit is contained in:
commit
00d4333373
9 changed files with 162 additions and 11 deletions
|
|
@ -951,4 +951,31 @@ defmodule Pleroma.UserTest do
|
|||
assert expected_text == User.parse_bio(bio, user)
|
||||
end
|
||||
end
|
||||
|
||||
test "bookmarks" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, activity1} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "heweoo!"
|
||||
})
|
||||
|
||||
id1 = activity1.data["object"]["id"]
|
||||
|
||||
{:ok, activity2} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "heweoo!"
|
||||
})
|
||||
|
||||
id2 = activity2.data["object"]["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
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1693,4 +1693,55 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
}
|
||||
end
|
||||
end
|
||||
|
||||
test "bookmarks" do
|
||||
user = insert(:user)
|
||||
for_user = insert(:user)
|
||||
|
||||
{:ok, activity1} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "heweoo?"
|
||||
})
|
||||
|
||||
{:ok, activity2} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "heweoo!"
|
||||
})
|
||||
|
||||
response1 =
|
||||
build_conn()
|
||||
|> assign(:user, for_user)
|
||||
|> post("/api/v1/statuses/#{activity1.id}/bookmark")
|
||||
|
||||
assert json_response(response1, 200)["bookmarked"] == true
|
||||
|
||||
response2 =
|
||||
build_conn()
|
||||
|> assign(:user, for_user)
|
||||
|> post("/api/v1/statuses/#{activity2.id}/bookmark")
|
||||
|
||||
assert json_response(response2, 200)["bookmarked"] == true
|
||||
|
||||
bookmarks =
|
||||
build_conn()
|
||||
|> assign(:user, for_user)
|
||||
|> get("/api/v1/bookmarks")
|
||||
|
||||
assert [json_response(response2, 200), json_response(response1, 200)] ==
|
||||
json_response(bookmarks, 200)
|
||||
|
||||
response1 =
|
||||
build_conn()
|
||||
|> assign(:user, for_user)
|
||||
|> post("/api/v1/statuses/#{activity1.id}/unbookmark")
|
||||
|
||||
assert json_response(response1, 200)["bookmarked"] == false
|
||||
|
||||
bookmarks =
|
||||
build_conn()
|
||||
|> assign(:user, for_user)
|
||||
|> get("/api/v1/bookmarks")
|
||||
|
||||
assert [json_response(response2, 200)] == json_response(bookmarks, 200)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
replies_count: 0,
|
||||
favourites_count: 0,
|
||||
reblogged: false,
|
||||
bookmarked: false,
|
||||
favourited: false,
|
||||
muted: false,
|
||||
pinned: false,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue