FIX: Auto re-opened topics should restore category auto close settings.
https://meta.discourse.org/t/topic-closed-temporarily-due-to-community-flags-overwrites-category-auto-close-timer/77421
This commit is contained in:
parent
83e8ab5274
commit
486bbe9cc2
|
@ -16,6 +16,7 @@ module Jobs
|
|||
|
||||
if Guardian.new(user).can_close?(topic)
|
||||
topic.update_status('autoclosed', state, user)
|
||||
topic.inherit_auto_close_from_category if state == false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -28,7 +28,8 @@ describe Jobs::ToggleTopicClosed do
|
|||
end
|
||||
end
|
||||
|
||||
it 'should be able to open a topic' do
|
||||
describe 'opening a topic' do
|
||||
it 'should be work' do
|
||||
topic.update!(closed: true)
|
||||
|
||||
freeze_time(1.hour.from_now) do
|
||||
|
@ -45,6 +46,34 @@ describe Jobs::ToggleTopicClosed do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'when category has auto close configured' do
|
||||
let(:category) { Fabricate(:category, auto_close_hours: 5) }
|
||||
let(:topic) { Fabricate(:topic, category: category, closed: true) }
|
||||
|
||||
it "should restore the category's auto close timer" do
|
||||
Fabricate(:topic_timer,
|
||||
status_type: TopicTimer.types[:open],
|
||||
topic: topic,
|
||||
user: admin
|
||||
)
|
||||
|
||||
freeze_time(1.hour.from_now) do
|
||||
described_class.new.execute(
|
||||
topic_timer_id: topic.public_topic_timer.id,
|
||||
state: false
|
||||
)
|
||||
|
||||
expect(topic.reload.closed).to eq(false)
|
||||
|
||||
topic_timer = topic.public_topic_timer
|
||||
|
||||
expect(topic_timer.status_type).to eq(TopicTimer.types[:close])
|
||||
expect(topic_timer.execute_at).to eq(5.hours.from_now)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when trying to close a topic that has been deleted' do
|
||||
it 'should not do anything' do
|
||||
topic.trash!
|
||||
|
|
Loading…
Reference in New Issue