Commit 3142e86d authored by webchick's avatar webchick

Issue #2401191 by jhedstrom, a_thakur, nlisgo, mohrerao: Activity Tracker...

Issue #2401191 by jhedstrom, a_thakur, nlisgo, mohrerao: Activity Tracker shows 'Last updated' status as '45 years 1 week ago'
parent cfdf10cf
......@@ -9,6 +9,7 @@
use Drupal\comment\CommentInterface;
use Drupal\comment\Tests\CommentTestTrait;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\simpletest\WebTestBase;
/**
......@@ -25,7 +26,7 @@ class TrackerTest extends WebTestBase {
*
* @var array
*/
public static $modules = array('comment', 'tracker', 'history');
public static $modules = array('comment', 'tracker', 'history', 'node_test');
/**
* The main user for testing.
......@@ -76,6 +77,21 @@ function testTrackerAll() {
$published->delete();
$this->drupalGet('activity');
$this->assertNoText($published->label(), 'Deleted node does not show up in the tracker listing.');
// Test proper display of time on activity page when comments are disabled.
// Disable comments.
FieldStorageConfig::loadByName('node', 'comment')->delete();
$node = $this->drupalCreateNode([
// This title is required to trigger the custom changed time set in the
// node_test module. This is needed in order to ensure a sufficiently
// large 'time ago' interval that isn't numbered in seconds.
'title' => 'testing_node_presave',
'status' => 1,
]);
$this->drupalGet('activity');
$this->assertText($node->label(), 'Published node shows up in the tracker listing.');
$this->assertText(\Drupal::service('date.formatter')->formatInterval(REQUEST_TIME - $node->getChangedTime()), 'The changed time was displayed on the tracker listing.');
}
/**
......
......@@ -61,12 +61,14 @@ function tracker_page($account = NULL) {
else {
$nodes[$nid]->comment_count += $statistics->comment_count;
}
$nodes[$nid]->last_activity = $tracker_data[$nid]->changed;
}
// Display the data.
foreach ($nodes as $node) {
// Set the last activity time from tracker data. This also takes into
// account comment activity, so getChangedTime() is not used.
$node->last_activity = $tracker_data[$node->id()]->changed;
// Determine the number of comments.
$comments = 0;
if ($node->comment_count) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment