Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Mastodon
Commits
d9271126
Unverified
Commit
d9271126
authored
2 years ago
by
Stanislav Dobrovolschii
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add rspecs for FollowRecommendationsScheduler (#23890)
parent
b6602f68
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
spec/fabricators/user_fabricator.rb
+2
-1
2 additions, 1 deletion
spec/fabricators/user_fabricator.rb
spec/workers/scheduler/follow_recommendations_scheduler_spec.rb
+43
-0
43 additions, 0 deletions
...orkers/scheduler/follow_recommendations_scheduler_spec.rb
with
45 additions
and
1 deletion
spec/fabricators/user_fabricator.rb
+
2
−
1
View file @
d9271126
...
...
@@ -5,5 +5,6 @@ Fabricator(:user) do
email
{
sequence
(
:email
)
{
|
i
|
"
#{
i
}#{
Faker
::
Internet
.
email
}
"
}
}
password
'123456789'
confirmed_at
{
Time
.
zone
.
now
}
agreement
true
current_sign_in_at
{
Time
.
zone
.
now
}
agreement
true
end
This diff is collapsed.
Click to expand it.
spec/workers/scheduler/follow_recommendations_scheduler_spec.rb
0 → 100644
+
43
−
0
View file @
d9271126
# frozen_string_literal: true
require
'rails_helper'
describe
Scheduler
::
FollowRecommendationsScheduler
do
let!
(
:target_accounts
)
do
Fabricate
.
times
(
3
,
:account
)
do
statuses
(
count:
6
)
end
end
let!
(
:follower_accounts
)
do
Fabricate
.
times
(
5
,
:account
)
do
statuses
(
count:
6
)
end
end
describe
'#perform'
do
subject
(
:scheduled_run
)
{
described_class
.
new
.
perform
}
context
'when there are accounts to recommend'
do
before
do
# Follow the target accounts by follow accounts to make them recommendable
follower_accounts
.
each
do
|
follower_account
|
target_accounts
.
each
do
|
target_account
|
Fabricate
(
:follow
,
account:
follower_account
,
target_account:
target_account
)
end
end
end
it
'creates recommendations'
do
expect
{
scheduled_run
}.
to
change
(
FollowRecommendation
,
:count
).
from
(
0
).
to
(
target_accounts
.
size
)
expect
(
redis
.
zrange
(
'follow_recommendations:en'
,
0
,
-
1
)).
to
match_array
(
target_accounts
.
pluck
(
:id
).
map
(
&
:to_s
))
end
end
context
'when there are no accounts to recommend'
do
it
'does not create follow recommendations'
do
expect
{
scheduled_run
}.
to_not
change
(
FollowRecommendation
,
:count
)
expect
(
redis
.
zrange
(
'follow_recommendations:en'
,
0
,
-
1
)).
to
be_empty
end
end
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