Fix Performance/TimesMap cop (#24789)
This commit is contained in:
		
					parent
					
						
							
								bae694108a
							
						
					
				
			
			
				commit
				
					
						570079f8ce
					
				
			
		
					 6 changed files with 15 additions and 24 deletions
				
			
		|  | @ -13,13 +13,13 @@ RSpec.describe Api::V1::BlocksController, type: :controller do | |||
| 
 | ||||
|   describe 'GET #index' do | ||||
|     it 'limits according to limit parameter' do | ||||
|       2.times.map { Fabricate(:block, account: user.account) } | ||||
|       Array.new(2) { Fabricate(:block, account: user.account) } | ||||
|       get :index, params: { limit: 1 } | ||||
|       expect(body_as_json.size).to eq 1 | ||||
|     end | ||||
| 
 | ||||
|     it 'queries blocks in range according to max_id' do | ||||
|       blocks = 2.times.map { Fabricate(:block, account: user.account) } | ||||
|       blocks = Array.new(2) { Fabricate(:block, account: user.account) } | ||||
| 
 | ||||
|       get :index, params: { max_id: blocks[1] } | ||||
| 
 | ||||
|  | @ -28,7 +28,7 @@ RSpec.describe Api::V1::BlocksController, type: :controller do | |||
|     end | ||||
| 
 | ||||
|     it 'queries blocks in range according to since_id' do | ||||
|       blocks = 2.times.map { Fabricate(:block, account: user.account) } | ||||
|       blocks = Array.new(2) { Fabricate(:block, account: user.account) } | ||||
| 
 | ||||
|       get :index, params: { since_id: blocks[0] } | ||||
| 
 | ||||
|  | @ -37,7 +37,7 @@ RSpec.describe Api::V1::BlocksController, type: :controller do | |||
|     end | ||||
| 
 | ||||
|     it 'sets pagination header for next path' do | ||||
|       blocks = 2.times.map { Fabricate(:block, account: user.account) } | ||||
|       blocks = Array.new(2) { Fabricate(:block, account: user.account) } | ||||
|       get :index, params: { limit: 1, since_id: blocks[0] } | ||||
|       expect(response.headers['Link'].find_link(%w(rel next)).href).to eq api_v1_blocks_url(limit: 1, max_id: blocks[1]) | ||||
|     end | ||||
|  |  | |||
|  | @ -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 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue