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

@ -13,13 +13,13 @@ RSpec.describe Api::V1::MutesController, type: :controller do
describe 'GET #index' do
it 'limits according to limit parameter' do
2.times.map { Fabricate(:mute, account: user.account) }
Array.new(2) { Fabricate(:mute, account: user.account) }
get :index, params: { limit: 1 }
expect(body_as_json.size).to eq 1
end
it 'queries mutes in range according to max_id' do
mutes = 2.times.map { Fabricate(:mute, account: user.account) }
mutes = Array.new(2) { Fabricate(:mute, account: user.account) }
get :index, params: { max_id: mutes[1] }
@ -28,7 +28,7 @@ RSpec.describe Api::V1::MutesController, type: :controller do
end
it 'queries mutes in range according to since_id' do
mutes = 2.times.map { Fabricate(:mute, account: user.account) }
mutes = Array.new(2) { Fabricate(:mute, account: user.account) }
get :index, params: { since_id: mutes[0] }
@ -37,7 +37,7 @@ RSpec.describe Api::V1::MutesController, type: :controller do
end
it 'sets pagination header for next path' do
mutes = 2.times.map { Fabricate(:mute, account: user.account) }
mutes = Array.new(2) { Fabricate(:mute, account: user.account) }
get :index, params: { limit: 1, since_id: mutes[0] }
expect(response.headers['Link'].find_link(%w(rel next)).href).to eq api_v1_mutes_url(limit: 1, max_id: mutes[1])
end