Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pleroma
pleroma
Commits
567651fb
Commit
567651fb
authored
Jan 09, 2019
by
kaniini
Browse files
test: user: add tests for visible_for?/2
parent
f2a4f89a
Pipeline
#6092
passed with stages
in 3 minutes and 38 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
test/user_test.exs
View file @
567651fb
...
...
@@ -809,4 +809,41 @@ test "returns true for local admins" do
assert
User
.
superuser?
(
user
)
end
end
describe
"visible_for?/2"
do
test
"returns true when the account is itself"
do
user
=
insert
(
:user
,
local:
true
)
assert
User
.
visible_for?
(
user
,
user
)
end
test
"returns false when the account is unauthenticated and auth is required"
do
Pleroma
.
Config
.
put
([
:instance
,
:account_activation_required
],
true
)
user
=
insert
(
:user
,
local:
true
,
info:
%{
confirmation_pending:
true
})
other_user
=
insert
(
:user
,
local:
true
)
refute
User
.
visible_for?
(
user
,
other_user
)
Pleroma
.
Config
.
put
([
:instance
,
:account_activation_required
],
false
)
end
test
"returns true when the account is unauthenticated and auth is not required"
do
user
=
insert
(
:user
,
local:
true
,
info:
%{
confirmation_pending:
true
})
other_user
=
insert
(
:user
,
local:
true
)
assert
User
.
visible_for?
(
user
,
other_user
)
end
test
"returns true when the account is unauthenticated and being viewed by a privileged account (auth required)"
do
Pleroma
.
Config
.
put
([
:instance
,
:account_activation_required
],
true
)
user
=
insert
(
:user
,
local:
true
,
info:
%{
confirmation_pending:
true
})
other_user
=
insert
(
:user
,
local:
true
,
info:
%{
is_admin:
true
})
assert
User
.
visible_for?
(
user
,
other_user
)
Pleroma
.
Config
.
put
([
:instance
,
:account_activation_required
],
false
)
end
end
end
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment