From 1607b4e107cc5fb3fe64d6fb8fca407c7c4d5fd1 Mon Sep 17 00:00:00 2001 From: jomaxro Date: Mon, 12 Jun 2017 16:29:53 -0400 Subject: [PATCH] FIX: Don't open a topic to set an auto-close timer when marking as solved. Fixes this issue: https://meta.discourse.org/t/marking-closed-topic-solved-with-solve-topics-auto-close-hours-set-causes-topic-to-be-reopened/63593?u=jomaxro Topics that were closed before being marked as solved would be reopened and have an auto-close timer set. If a topic is already closed, marking as solved should not cause it to re-open. --- plugin.rb | 2 +- spec/integration/solved_spec.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/plugin.rb b/plugin.rb index 6db948e..9388a8d 100644 --- a/plugin.rb +++ b/plugin.rb @@ -108,7 +108,7 @@ SQL ) end - if (auto_close_hours = SiteSetting.solved_topics_auto_close_hours) > 0 + if (auto_close_hours = SiteSetting.solved_topics_auto_close_hours) > 0 and !topic.closed topic.set_or_create_timer( TopicTimer.types[:close], auto_close_hours, diff --git a/spec/integration/solved_spec.rb b/spec/integration/solved_spec.rb index 73891e8..5dd6afe 100644 --- a/spec/integration/solved_spec.rb +++ b/spec/integration/solved_spec.rb @@ -27,5 +27,18 @@ RSpec.describe "Managing Posts solved status" do expect(topic.public_topic_timer.based_on_last_post).to eq(true) end + it 'does not set a timer when the topic is closed' do + topic2.update!(closed: true) + xhr :post, "/solution/accept", id: p2.id + + p2.reload + topic2.reload + + expect(p2.custom_fields["is_accepted_answer"]).to eq("true") + + expect(topic2.public_topic_timer).to eq(nil) + + expect(topic2.closed).to eq(true) + end end end