A platform for community discussion. Free, open, simple.
FEATURE: Hide topic if OP is hidden (#33201)
Gabriel Grubba475baff2bb5c
diff --git a/app/models/post.rb b/app/models/post.rbindex 4a23f3dbe5c..ffff3be4d32 100644--- a/app/models/post.rb+++ b/app/models/post.rb@@ -635,7 +635,7 @@ class Post < ActiveRecord::Baseany_visible_posts_in_topic =Post.exists?(topic_id: topic_id, hidden: false, post_type: Post.types[:regular])- if !any_visible_posts_in_topic+ if is_first_post? || !any_visible_posts_in_topicself.topic.update_status("visible",false,diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rbindex c6c7349575b..b035fc3a133 100644--- a/spec/models/post_spec.rb+++ b/spec/models/post_spec.rb@@ -1549,6 +1549,16 @@ RSpec.describe Post dopost_2.user.user_stat.reload.post_count}.from(1).to(0)end++ it "changes topic visible status to false if it is the first post" do+ t = post.topic+ expect(t.visible).to eq(true)++ post.hide!(PostActionType.types[:off_topic])++ t.reload+ expect(t.visible).to eq(false)+ endenddescribe "#unhide!" do