FIX: When re-opening a topic that auto-closed, make sure it won't auto-close again

This commit is contained in:
Neil Lalonde 2013-12-19 11:24:21 -05:00
parent c2f0bdcf49
commit c35af5d755
2 changed files with 9 additions and 1 deletions

View File

@ -22,7 +22,7 @@ TopicStatusUpdate = Struct.new(:topic, :user) do
topic.update_column status.name, status.enabled?
end
if status.manually_closing_topic? && topic.auto_close_at
if topic.auto_close_at && (status.reopening_topic? || status.manually_closing_topic?)
topic.reload.set_auto_close(nil).save
end

View File

@ -87,6 +87,14 @@ describe Topic do
Then { scheduled_jobs_for(:close_topic).should have(2).jobs }
end
end
context 'a topic that has been auto-closed' do
Given(:admin) { Fabricate(:admin) }
Given!(:auto_closed_topic) { Fabricate(:topic, user: admin, closed: true, auto_close_at: 1.day.ago, auto_close_user_id: admin.id, auto_close_started_at: 6.days.ago) }
When { auto_closed_topic.update_status('closed', false, admin) }
Then { auto_closed_topic.reload.auto_close_at.should be_nil }
And { auto_closed_topic.auto_close_started_at.should be_nil }
end
end
end
end