mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Don't set topic timer for close topics when changing category.
https://meta.discourse.org/t/moving-a-topic-after-closure-reopens-topic/67659/4
This commit is contained in:
parent
2d4d76472d
commit
87994a86ce
@ -216,7 +216,8 @@ class Topic < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def inherit_auto_close_from_category
|
def inherit_auto_close_from_category
|
||||||
if !@ignore_category_auto_close &&
|
if !self.closed &&
|
||||||
|
!@ignore_category_auto_close &&
|
||||||
self.category &&
|
self.category &&
|
||||||
self.category.auto_close_hours &&
|
self.category.auto_close_hours &&
|
||||||
!public_topic_timer&.execute_at
|
!public_topic_timer&.execute_at
|
||||||
@ -1010,7 +1011,7 @@ SQL
|
|||||||
topic_timer.status_type = status_type
|
topic_timer.status_type = status_type
|
||||||
|
|
||||||
if time.blank?
|
if time.blank?
|
||||||
topic_timer.trash!(trashed_by: by_user || Discourse.system_user)
|
topic_timer.trash!(by_user || Discourse.system_user)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1066,6 +1066,21 @@ describe Topic do
|
|||||||
expect(topic_timer.execute_at).to be_within(1.second).of(Time.zone.now + 5.hours)
|
expect(topic_timer.execute_at).to be_within(1.second).of(Time.zone.now + 5.hours)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'when topic is already closed' do
|
||||||
|
before do
|
||||||
|
SiteSetting.queue_jobs = true
|
||||||
|
topic.update_status('closed', true, Discourse.system_user)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should not set a topic timer' do
|
||||||
|
expect { topic.change_category_to_id(new_category.id) }
|
||||||
|
.to change { TopicTimer.with_deleted.count }.by(0)
|
||||||
|
|
||||||
|
expect(topic.closed).to eq(true)
|
||||||
|
expect(topic.reload.category).to eq(new_category)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'when topic has an existing topic timer' do
|
describe 'when topic has an existing topic timer' do
|
||||||
let(:topic_timer) { Fabricate(:topic_timer, topic: topic) }
|
let(:topic_timer) { Fabricate(:topic_timer, topic: topic) }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user