Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mastodon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pierre Boudes
mastodon
Commits
338df98d
Commit
338df98d
authored
7 years ago
by
Eugen
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add more FeedManager#filter? tests (#2413)
parent
da022e1e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
spec/lib/feed_manager_spec.rb
+109
-6
109 additions, 6 deletions
spec/lib/feed_manager_spec.rb
spec/models/status_spec.rb
+8
-0
8 additions, 0 deletions
spec/models/status_spec.rb
with
117 additions
and
6 deletions
spec/lib/feed_manager_spec.rb
+
109
−
6
View file @
338df98d
...
...
@@ -10,14 +10,117 @@ RSpec.describe FeedManager do
end
describe
'#filter?'
do
let
(
:
followe
e
)
{
Fabricate
(
:account
,
username:
'alice'
)
}
let
(
:
status
)
{
Fabricate
(
:
status
,
text:
'Hello world'
,
account:
followee
)
}
let
(
:
follower
)
{
Fabricate
(
:account
,
username:
'
bob
'
)
}
let
(
:
alic
e
)
{
Fabricate
(
:account
,
username:
'alice'
)
}
let
(
:
bob
)
{
Fabricate
(
:
account
,
username:
'bob'
)
}
let
(
:
jeff
)
{
Fabricate
(
:account
,
username:
'
jeff
'
)
}
subject
{
FeedManager
.
instance
.
filter?
(
:home
,
status
,
follower
)
}
context
'for home feed'
do
it
'returns false for followee\'s status'
do
status
=
Fabricate
(
:status
,
text:
'Hello world'
,
account:
alice
)
bob
.
follow!
(
alice
)
expect
(
FeedManager
.
instance
.
filter?
(
:home
,
status
,
bob
.
id
)).
to
be
false
end
it
'returns a boolean value'
do
expect
(
subject
).
to
be
false
it
'returns false for reblog by followee'
do
status
=
Fabricate
(
:status
,
text:
'Hello world'
,
account:
jeff
)
reblog
=
Fabricate
(
:status
,
reblog:
status
,
account:
alice
)
bob
.
follow!
(
alice
)
expect
(
FeedManager
.
instance
.
filter?
(
:home
,
reblog
,
bob
.
id
)).
to
be
false
end
it
'returns true for reblog by followee of blocked account'
do
status
=
Fabricate
(
:status
,
text:
'Hello world'
,
account:
jeff
)
reblog
=
Fabricate
(
:status
,
reblog:
status
,
account:
alice
)
bob
.
follow!
(
alice
)
bob
.
block!
(
jeff
)
expect
(
FeedManager
.
instance
.
filter?
(
:home
,
reblog
,
bob
.
id
)).
to
be
true
end
it
'returns true for reblog by followee of muted account'
do
status
=
Fabricate
(
:status
,
text:
'Hello world'
,
account:
jeff
)
reblog
=
Fabricate
(
:status
,
reblog:
status
,
account:
alice
)
bob
.
follow!
(
alice
)
bob
.
mute!
(
jeff
)
expect
(
FeedManager
.
instance
.
filter?
(
:home
,
reblog
,
bob
.
id
)).
to
be
true
end
it
'returns true for reblog by followee of someone who is blocking recipient'
do
status
=
Fabricate
(
:status
,
text:
'Hello world'
,
account:
jeff
)
reblog
=
Fabricate
(
:status
,
reblog:
status
,
account:
alice
)
bob
.
follow!
(
alice
)
jeff
.
block!
(
bob
)
expect
(
FeedManager
.
instance
.
filter?
(
:home
,
reblog
,
bob
.
id
)).
to
be
true
end
it
'returns false for reply by followee to another followee'
do
status
=
Fabricate
(
:status
,
text:
'Hello world'
,
account:
jeff
)
reply
=
Fabricate
(
:status
,
text:
'Nay'
,
thread:
status
,
account:
alice
)
bob
.
follow!
(
alice
)
bob
.
follow!
(
jeff
)
expect
(
FeedManager
.
instance
.
filter?
(
:home
,
reply
,
bob
.
id
)).
to
be
false
end
it
'returns false for reply by followee to recipient'
do
status
=
Fabricate
(
:status
,
text:
'Hello world'
,
account:
bob
)
reply
=
Fabricate
(
:status
,
text:
'Nay'
,
thread:
status
,
account:
alice
)
bob
.
follow!
(
alice
)
expect
(
FeedManager
.
instance
.
filter?
(
:home
,
reply
,
bob
.
id
)).
to
be
false
end
it
'returns false for reply by followee to self'
do
status
=
Fabricate
(
:status
,
text:
'Hello world'
,
account:
alice
)
reply
=
Fabricate
(
:status
,
text:
'Nay'
,
thread:
status
,
account:
alice
)
bob
.
follow!
(
alice
)
expect
(
FeedManager
.
instance
.
filter?
(
:home
,
reply
,
bob
.
id
)).
to
be
false
end
it
'returns true for reply by followee to non-followed account'
do
status
=
Fabricate
(
:status
,
text:
'Hello world'
,
account:
jeff
)
reply
=
Fabricate
(
:status
,
text:
'Nay'
,
thread:
status
,
account:
alice
)
bob
.
follow!
(
alice
)
expect
(
FeedManager
.
instance
.
filter?
(
:home
,
reply
,
bob
.
id
)).
to
be
true
end
it
'returns false for status by followee mentioning another account'
do
bob
.
follow!
(
alice
)
status
=
PostStatusService
.
new
.
call
(
alice
,
'Hey @jeff'
)
expect
(
FeedManager
.
instance
.
filter?
(
:home
,
status
,
bob
.
id
)).
to
be
false
end
it
'returns true for status by followee mentioning blocked account'
do
bob
.
block!
(
jeff
)
bob
.
follow!
(
alice
)
status
=
PostStatusService
.
new
.
call
(
alice
,
'Hey @jeff'
)
expect
(
FeedManager
.
instance
.
filter?
(
:home
,
status
,
bob
.
id
)).
to
be
true
end
end
context
'for mentions feed'
do
it
'returns true for status that mentions blocked account'
do
bob
.
block!
(
jeff
)
status
=
PostStatusService
.
new
.
call
(
alice
,
'Hey @jeff'
)
expect
(
FeedManager
.
instance
.
filter?
(
:mentions
,
status
,
bob
.
id
)).
to
be
true
end
it
'returns true for status that replies to a blocked account'
do
status
=
Fabricate
(
:status
,
text:
'Hello world'
,
account:
jeff
)
reply
=
Fabricate
(
:status
,
text:
'Nay'
,
thread:
status
,
account:
alice
)
bob
.
block!
(
jeff
)
expect
(
FeedManager
.
instance
.
filter?
(
:mentions
,
reply
,
bob
.
id
)).
to
be
true
end
it
'returns true for status by silenced account who recipient is not following'
do
status
=
Fabricate
(
:status
,
text:
'Hello world'
,
account:
alice
)
alice
.
update
(
silenced:
true
)
expect
(
FeedManager
.
instance
.
filter?
(
:mentions
,
status
,
bob
.
id
)).
to
be
true
end
it
'returns false for status by followed silenced account'
do
status
=
Fabricate
(
:status
,
text:
'Hello world'
,
account:
alice
)
alice
.
update
(
silenced:
true
)
bob
.
follow!
(
alice
)
expect
(
FeedManager
.
instance
.
filter?
(
:mentions
,
status
,
bob
.
id
)).
to
be
false
end
end
end
end
This diff is collapsed.
Click to expand it.
spec/models/status_spec.rb
+
8
−
0
View file @
338df98d
...
...
@@ -118,4 +118,12 @@ RSpec.describe Status, type: :model do
expect
(
subject
.
proper
).
to
eq
other
end
end
describe
'#permitted?'
do
pending
end
describe
'#filter_from_context?'
do
pending
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment