Skip to content
Snippets Groups Projects
Commit e08b17dd authored by David Cameron's avatar David Cameron
Browse files

Issue #3214630 by dcam, larowlan: Invalidate /aggregator page cache when feeds update

parent 2f1c02ac
No related branches found
No related tags found
No related merge requests found
......@@ -176,6 +176,7 @@ class AggregatorController extends ControllerBase {
$items = $this->entityTypeManager()->getStorage('aggregator_item')->loadAll(20);
$build = $this->buildPageList($items);
$build['#attached']['feed'][] = ['aggregator/rss', $this->config('system.site')->get('name') . ' ' . $this->t('aggregator')];
$build['#cache']['tags'] = $this->entityTypeManager()->getDefinition('aggregator_item')->getListCacheTags();
return $build;
}
......
......@@ -96,9 +96,21 @@ class AggregatorRenderingTest extends AggregatorTestBase {
// Create a feed with 30 items.
$this->createSampleNodes(30);
// Request the /aggregator page so that it is cached.
$this->drupalGet('aggregator');
$feed = $this->createFeed();
$this->updateFeedItems($feed, 30);
// Verify that items are loaded on the page by checking for the pager.
$this->drupalGet('aggregator');
$this->assertSession()->elementExists('xpath', '//ul[contains(@class, "pager__items")]');
// Save the feed entity to invalidate the cache so that the paginated cache
// context can be tested.
$feed->save();
// Request page with no feed items to ensure cache context is set correctly.
$this->drupalGet('aggregator', ['query' => ['page' => 2]]);
// Check for presence of an aggregator pager.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment