Fix the build

Fix the build

From e32cdb00cbdd856774df720ec858ac377e3ea307 Mon Sep 17 00:00:00 2001
From: David Taylor <david@taylorhq.com>
Date: Mon, 3 Dec 2018 18:51:07 +0000
Subject: [PATCH] Fix the build


diff --git a/lib/validators/post_validator.rb b/lib/validators/post_validator.rb
index b441ecc..0629b7c 100644
--- a/lib/validators/post_validator.rb
+++ b/lib/validators/post_validator.rb
@@ -146,7 +146,7 @@ class Validators::PostValidator < ActiveModel::Validator
     return if SiteSetting.max_consecutive_replies == 0 || post.id || post.acting_user&.staff? || private_message?(post)
 
     topic = post.topic
-    return if topic&.first&.user == post.user
+    return if topic&.posts.first&.user == post.user
 
     last_posts_count = DB.query_single(<<~SQL, topic_id: post.topic_id, user_id: post.acting_user.id, max_replies: SiteSetting.max_consecutive_replies).first
       SELECT COUNT(*)

GitHub

2 Likes

Added a followup here, to add a test tomorrow.

1 Like

We have tests which would have picked this up, but the site setting had been disabled in the test suite. Corrected in DEV: Run tests with default value for `max_consecutive_replies` by davidtaylorhq · Pull Request #6723 · discourse/discourse · GitHub

2 Likes