From d1f61015c0143b1c87e8dc89175b28301ba48669 Mon Sep 17 00:00:00 2001 From: shaktikatare1989 Date: Mon, 25 Apr 2016 14:03:38 +0530 Subject: [PATCH] Fix: Editing a topic with an invalid title will still push it to the top (#4185) * fix: Editing a topic with an invalid title will still push it to the top * add specs to check topic not bumped with invalid title --- lib/post_revisor.rb | 2 +- spec/models/topic_spec.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/post_revisor.rb b/lib/post_revisor.rb index 05c85d0fa5e..093b55c9246 100644 --- a/lib/post_revisor.rb +++ b/lib/post_revisor.rb @@ -363,7 +363,7 @@ class PostRevisor end def bypass_bump? - !@post_successfully_saved || @opts[:bypass_bump] == true + !@post_successfully_saved || @topic_changes.errored? || @opts[:bypass_bump] == true end def is_last_post? diff --git a/spec/models/topic_spec.rb b/spec/models/topic_spec.rb index 4ae8009f372..e9b8b84cffe 100644 --- a/spec/models/topic_spec.rb +++ b/spec/models/topic_spec.rb @@ -488,6 +488,13 @@ describe Topic do @topic.reload }.not_to change(@topic, :bumped_at) end + + it "doesn't bump the topic when a post have invalid topic title while edit" do + expect { + @last_post.revise(Fabricate(:moderator), { title: 'invalid title' }) + @topic.reload + }.not_to change(@topic, :bumped_at) + end end end