Fix cached posts including stale stats (#26409)
This commit is contained in:
parent
3ed2bf92d0
commit
60b9fa641d
2 changed files with 34 additions and 2 deletions
|
@ -13,12 +13,17 @@ RSpec.describe CacheConcern do
|
|||
def empty_relation
|
||||
render plain: cache_collection(Status.none, Status).size
|
||||
end
|
||||
|
||||
def account_statuses_favourites
|
||||
render plain: cache_collection(Status.where(account_id: params[:id]), Status).map(&:favourites_count)
|
||||
end
|
||||
end
|
||||
|
||||
before do
|
||||
routes.draw do
|
||||
get 'empty_array' => 'anonymous#empty_array'
|
||||
post 'empty_relation' => 'anonymous#empty_relation'
|
||||
get 'empty_array' => 'anonymous#empty_array'
|
||||
get 'empty_relation' => 'anonymous#empty_relation'
|
||||
get 'account_statuses_favourites' => 'anonymous#account_statuses_favourites'
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -36,5 +41,20 @@ RSpec.describe CacheConcern do
|
|||
expect(response.body).to eq '0'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when given a collection of statuses' do
|
||||
let!(:account) { Fabricate(:account) }
|
||||
let!(:status) { Fabricate(:status, account: account) }
|
||||
|
||||
it 'correctly updates with new interactions' do
|
||||
get :account_statuses_favourites, params: { id: account.id }
|
||||
expect(response.body).to eq '[0]'
|
||||
|
||||
FavouriteService.new.call(account, status)
|
||||
|
||||
get :account_statuses_favourites, params: { id: account.id }
|
||||
expect(response.body).to eq '[1]'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue