Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F7686866
bookmark_test.exs
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
bookmark_test.exs
View Options
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
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
describe
"get/2"
do
test
"gets a bookmark"
do
user
=
insert
(
:user
)
{
:ok
,
activity
}
=
CommonAPI
.
post
(
user
,
%{
"status"
=>
"Scientists Discover The Secret Behind Tenshi Eating A Corndog Being So Cute – Science Daily"
})
{
:ok
,
bookmark
}
=
Bookmark
.
create
(
user
.
id
,
activity
.
id
)
assert
bookmark
==
Bookmark
.
get
(
user
.
id
,
activity
.
id
)
end
end
end
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Sep 3, 5:20 PM (19 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
437704
Default Alt Text
bookmark_test.exs (1 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment