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
ae9f5379
Unverified
Commit
ae9f5379
authored
1 year ago
by
Matt Jankowski
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Reduce factory data created in spec/models/trends/statuses spec (#25410)
parent
31d5bc89
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
spec/models/trends/statuses_spec.rb
+13
-10
13 additions, 10 deletions
spec/models/trends/statuses_spec.rb
with
13 additions
and
10 deletions
spec/models/trends/statuses_spec.rb
+
13
−
10
View file @
ae9f5379
...
...
@@ -15,8 +15,8 @@ RSpec.describe Trends::Statuses do
let!
(
:status2
)
{
Fabricate
(
:status
,
text:
'Bar'
,
language:
'en'
,
trendable:
true
,
created_at:
today
)
}
before
do
15
.
times
{
reblog
(
status1
,
today
)
}
12
.
times
{
reblog
(
status2
,
today
)
}
default_threshold_value
.
times
{
reblog
(
status1
,
today
)
}
default_threshold_value
.
times
{
reblog
(
status2
,
today
)
}
subject
.
refresh
(
today
)
end
...
...
@@ -76,9 +76,9 @@ RSpec.describe Trends::Statuses do
let!
(
:status3
)
{
Fabricate
(
:status
,
text:
'Baz'
,
language:
'en'
,
trendable:
true
,
created_at:
today
)
}
before
do
13
.
times
{
reblog
(
status1
,
today
)
}
13
.
times
{
reblog
(
status2
,
today
)
}
4
.
times
{
reblog
(
status3
,
today
)
}
default_threshold_value
.
times
{
reblog
(
status1
,
today
)
}
default_threshold_value
.
times
{
reblog
(
status2
,
today
)
}
(
default_threshold_value
-
1
)
.
times
{
reblog
(
status3
,
today
)
}
end
context
'when status trends are refreshed'
do
...
...
@@ -86,12 +86,11 @@ RSpec.describe Trends::Statuses do
subject
.
refresh
(
today
)
end
it
'calculates and re-calculates scores'
do
expect
(
subject
.
query
.
limit
(
10
).
to_a
).
to
eq
[
status2
,
status1
]
end
it
'returns correct statuses from query'
do
results
=
subject
.
query
.
limit
(
10
).
to_a
it
'omits statuses below threshold'
do
expect
(
subject
.
query
.
limit
(
10
).
to_a
).
to_not
include
(
status3
)
expect
(
results
).
to
eq
[
status2
,
status1
]
expect
(
results
).
to_not
include
(
status3
)
end
end
...
...
@@ -109,4 +108,8 @@ RSpec.describe Trends::Statuses do
reblog
=
Fabricate
(
:status
,
reblog:
status
,
created_at:
at_time
)
subject
.
add
(
status
,
reblog
.
account_id
,
at_time
)
end
def
default_threshold_value
described_class
.
default_options
[
:threshold
]
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