0
0
Fork 0

Fix Performance/TimesMap cop (#24789)

This commit is contained in:
Matt Jankowski 2023-05-02 12:07:16 -04:00 committed by GitHub
parent bae694108a
commit 570079f8ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 15 additions and 24 deletions

View file

@ -188,7 +188,7 @@ RSpec.describe FeedManager do
it 'trims timelines if they will have more than FeedManager::MAX_ITEMS' do
account = Fabricate(:account)
status = Fabricate(:status)
members = FeedManager::MAX_ITEMS.times.map { |count| [count, count] }
members = Array.new(FeedManager::MAX_ITEMS) { |count| [count, count] }
redis.zadd("feed:home:#{account.id}", members)
FeedManager.instance.push_to_home(account, status)
@ -233,7 +233,7 @@ RSpec.describe FeedManager do
it 'does not save a new reblog of a recently-reblogged status' do
account = Fabricate(:account)
reblogged = Fabricate(:status)
reblogs = 2.times.map { Fabricate(:status, reblog: reblogged) }
reblogs = Array.new(2) { Fabricate(:status, reblog: reblogged) }
# The first reblog will be accepted
FeedManager.instance.push_to_home(account, reblogs.first)
@ -262,7 +262,7 @@ RSpec.describe FeedManager do
it 'does not save a new reblog of a multiply-reblogged-then-unreblogged status' do
account = Fabricate(:account)
reblogged = Fabricate(:status)
reblogs = 3.times.map { Fabricate(:status, reblog: reblogged) }
reblogs = Array.new(3) { Fabricate(:status, reblog: reblogged) }
# Accept the reblogs
FeedManager.instance.push_to_home(account, reblogs[0])
@ -278,7 +278,7 @@ RSpec.describe FeedManager do
it 'saves a new reblog of a long-ago-reblogged status' do
account = Fabricate(:account)
reblogged = Fabricate(:status)
reblogs = 2.times.map { Fabricate(:status, reblog: reblogged) }
reblogs = Array.new(2) { Fabricate(:status, reblog: reblogged) }
# The first reblog will be accepted
FeedManager.instance.push_to_home(account, reblogs.first)
@ -459,7 +459,7 @@ RSpec.describe FeedManager do
it 'leaves a multiply-reblogged status if another reblog was in feed' do
reblogged = Fabricate(:status)
reblogs = 3.times.map { Fabricate(:status, reblog: reblogged) }
reblogs = Array.new(3) { Fabricate(:status, reblog: reblogged) }
reblogs.each do |reblog|
FeedManager.instance.push_to_home(receiver, reblog)