FIX: Ensure autoclose based on last post is executed by system user.

This commit is contained in:
Guo Xiang Tan 2020-08-26 12:08:46 +08:00
parent ffc5bb7278
commit 1e8f216e17
No known key found for this signature in database
GPG Key ID: FBD110179AAC1F20
2 changed files with 3 additions and 0 deletions

View File

@ -380,6 +380,7 @@ class Topic < ActiveRecord::Base
self.set_or_create_timer( self.set_or_create_timer(
TopicTimer.types[:close], TopicTimer.types[:close],
self.category.auto_close_hours, self.category.auto_close_hours,
by_user: Discourse.system_user,
based_on_last_post: based_on_last_post, based_on_last_post: based_on_last_post,
duration: duration duration: duration
) )

View File

@ -1580,6 +1580,7 @@ describe Topic do
describe 'when new category is set to auto close by default' do describe 'when new category is set to auto close by default' do
before do before do
new_category.update!(auto_close_hours: 5) new_category.update!(auto_close_hours: 5)
topic.user.update!(admin: true)
end end
it 'should set a topic timer' do it 'should set a topic timer' do
@ -1592,6 +1593,7 @@ describe Topic do
topic_timer = TopicTimer.last topic_timer = TopicTimer.last
expect(topic_timer.user).to eq(Discourse.system_user)
expect(topic_timer.topic).to eq(topic) expect(topic_timer.topic).to eq(topic)
expect(topic_timer.execute_at).to eq_time(5.hours.from_now) expect(topic_timer.execute_at).to eq_time(5.hours.from_now)
end end