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)
|
if Guardian.new(user).can_close?(topic)
|
||||||
topic.update_status('autoclosed', state, user)
|
topic.update_status('autoclosed', state, user)
|
||||||
|
topic.inherit_auto_close_from_category if state == false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,20 +28,49 @@ describe Jobs::ToggleTopicClosed do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be able to open a topic' do
|
describe 'opening a topic' do
|
||||||
topic.update!(closed: true)
|
it 'should be work' do
|
||||||
|
topic.update!(closed: true)
|
||||||
|
|
||||||
freeze_time(1.hour.from_now) do
|
freeze_time(1.hour.from_now) do
|
||||||
described_class.new.execute(
|
described_class.new.execute(
|
||||||
topic_timer_id: topic.public_topic_timer.id,
|
topic_timer_id: topic.public_topic_timer.id,
|
||||||
state: false
|
state: false
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(topic.reload.closed).to eq(false)
|
expect(topic.reload.closed).to eq(false)
|
||||||
|
|
||||||
expect(Post.last.raw).to eq(I18n.t(
|
expect(Post.last.raw).to eq(I18n.t(
|
||||||
'topic_statuses.autoclosed_disabled_minutes', count: 60
|
'topic_statuses.autoclosed_disabled_minutes', count: 60
|
||||||
))
|
))
|
||||||
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue