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
b5675e26
Unverified
Commit
b5675e26
authored
1 year ago
by
Matt Jankowski
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Add coverage for `CLI::Feeds` command (#25319)
parent
07933db7
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
lib/mastodon/cli/feeds.rb
+7
-1
7 additions, 1 deletion
lib/mastodon/cli/feeds.rb
spec/lib/mastodon/cli/feeds_spec.rb
+56
-0
56 additions, 0 deletions
spec/lib/mastodon/cli/feeds_spec.rb
with
63 additions
and
1 deletion
lib/mastodon/cli/feeds.rb
+
7
−
1
View file @
b5675e26
...
...
@@ -19,7 +19,7 @@ module Mastodon::CLI
LONG_DESC
def
build
(
username
=
nil
)
if
options
[
:all
]
||
username
.
nil?
processed
,
=
parallelize_with_progress
(
Account
.
joins
(
:user
).
merge
(
User
.
active
)
)
do
|
account
|
processed
,
=
parallelize_with_progress
(
active_user_accounts
)
do
|
account
|
PrecomputeFeedService
.
new
.
call
(
account
)
unless
dry_run?
end
...
...
@@ -47,5 +47,11 @@ module Mastodon::CLI
redis
.
del
(
keys
)
say
(
'OK'
,
:green
)
end
private
def
active_user_accounts
Account
.
joins
(
:user
).
merge
(
User
.
active
)
end
end
end
This diff is collapsed.
Click to expand it.
spec/lib/mastodon/cli/feeds_spec.rb
+
56
−
0
View file @
b5675e26
...
...
@@ -4,9 +4,65 @@ require 'rails_helper'
require
'mastodon/cli/feeds'
describe
Mastodon
::
CLI
::
Feeds
do
let
(
:cli
)
{
described_class
.
new
}
describe
'.exit_on_failure?'
do
it
'returns true'
do
expect
(
described_class
.
exit_on_failure?
).
to
be
true
end
end
describe
'#build'
do
before
{
Fabricate
(
:account
)
}
context
'with --all option'
do
let
(
:options
)
{
{
all:
true
}
}
it
'regenerates feeds for all accounts'
do
expect
{
cli
.
invoke
(
:build
,
[],
options
)
}.
to
output
(
a_string_including
(
'Regenerated feeds'
)
).
to_stdout
end
end
context
'with a username'
do
before
{
Fabricate
(
:account
,
username:
'alice'
)
}
let
(
:arguments
)
{
[
'alice'
]
}
it
'regenerates feeds for the account'
do
expect
{
cli
.
invoke
(
:build
,
arguments
)
}.
to
output
(
a_string_including
(
'OK'
)
).
to_stdout
end
end
context
'with invalid username'
do
let
(
:arguments
)
{
[
'invalid-username'
]
}
it
'displays an error and exits'
do
expect
{
cli
.
invoke
(
:build
,
arguments
)
}.
to
output
(
a_string_including
(
'No such account'
)
).
to_stdout
.
and
raise_error
(
SystemExit
)
end
end
end
describe
'#clear'
do
before
do
allow
(
redis
).
to
receive
(
:del
).
with
(
key_namespace
)
end
it
'clears the redis `feed:*` namespace'
do
expect
{
cli
.
invoke
(
:clear
)
}.
to
output
(
a_string_including
(
'OK'
)
).
to_stdout
expect
(
redis
).
to
have_received
(
:del
).
with
(
key_namespace
).
once
end
def
key_namespace
redis
.
keys
(
'feed:*'
)
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