Skip to content

Commit 06f3376

Browse files
authored
Prevent timestamp update (#818)
1 parent 313201b commit 06f3376

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

app/Listeners/MarkLastActivity.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public function handle(ReplyWasCreated $event): void
1212
{
1313
$replyAble = $event->reply->replyAble();
1414
$replyAble->last_activity_at = now();
15+
$replyAble->timestamps = false;
1516
$replyAble->save();
1617
}
1718
}

tests/Feature/ReplyTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,17 @@
123123

124124
$this->assertNotNull($thread->fresh()->last_activity_at);
125125
});
126+
127+
test('replyable updated_at timestamp is not touched when reply is created', function () {
128+
$thread = Thread::factory()->create(['subject' => 'The first thread', 'slug' => 'the-first-thread', 'updated_at' => '1970-01-01']);
129+
130+
$this->login();
131+
132+
$this->post('/replies', [
133+
'body' => 'The first reply',
134+
'replyable_id' => $thread->id,
135+
'replyable_type' => Thread::TABLE,
136+
]);
137+
138+
$this->assertSame('1970-01-01', $thread->fresh()->updated_at->format('Y-m-d'));
139+
});

0 commit comments

Comments
 (0)