Use likes and shares totalItems on status creations and updates (#32620)
		
	This commit is contained in:
		
					parent
					
						
							
								77cd16f4ee
							
						
					
				
			
			
				commit
				
					
						9074c1fac9
					
				
			
		
					 14 changed files with 326 additions and 14 deletions
				
			
		|  | @ -39,6 +39,42 @@ RSpec.describe 'API V1 Trends Statuses' do | |||
|         end | ||||
|         Trends::Statuses.new(threshold: 1, decay_threshold: -1).refresh | ||||
|       end | ||||
| 
 | ||||
|       context 'with a comically inflated external interactions count' do | ||||
|         def prepare_fake_trends | ||||
|           fake_remote_account = Fabricate(:account, domain: 'other.com') | ||||
|           fake_status = Fabricate(:status, account: fake_remote_account, text: 'I am a big faker', trendable: true, language: 'en') | ||||
|           fake_status.status_stat.tap do |status_stat| | ||||
|             status_stat.reblogs_count = 0 | ||||
|             status_stat.favourites_count = 0 | ||||
|             status_stat.untrusted_reblogs_count = 1_000_000_000 | ||||
|             status_stat.untrusted_favourites_count = 1_000_000_000 | ||||
|             status_stat.save | ||||
|           end | ||||
|           real_remote_account = Fabricate(:account, domain: 'other.com') | ||||
|           real_status = Fabricate(:status, account: real_remote_account, text: 'I make real friends online', trendable: true, language: 'en') | ||||
|           real_status.status_stat.tap do |status_stat| | ||||
|             status_stat.reblogs_count = 10 | ||||
|             status_stat.favourites_count = 10 | ||||
|             status_stat.untrusted_reblogs_count = 10 | ||||
|             status_stat.untrusted_favourites_count = 10 | ||||
|             status_stat.save | ||||
|           end | ||||
|           Trends.statuses.add(fake_status, 100) | ||||
|           Trends.statuses.add(real_status, 101) | ||||
|           Trends::Statuses.new(threshold: 1, decay_threshold: 1).refresh | ||||
|         end | ||||
| 
 | ||||
|         it 'ignores the feeble attempts at deception' do | ||||
|           prepare_fake_trends | ||||
|           stub_const('Api::BaseController::DEFAULT_STATUSES_LIMIT', 10) | ||||
|           get '/api/v1/trends/statuses' | ||||
| 
 | ||||
|           expect(response).to have_http_status(200) | ||||
|           expect(response.parsed_body.length).to eq(1) | ||||
|           expect(response.parsed_body[0]['content']).to eq('I make real friends online') | ||||
|         end | ||||
|       end | ||||
|     end | ||||
|   end | ||||
| end | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue