FIX: Topics should honor auto-close when published to category (#8963)

* FIX: Topics should honor auto-close when published to category

* Add test
This commit is contained in:
tshenry
2020-03-02 11:21:35 -08:00
committed by GitHub
parent 5c39e21c18
commit a09e5d12c2
2 changed files with 20 additions and 0 deletions

View File

@@ -84,4 +84,22 @@ RSpec.describe Jobs::PublishTopicToCategory do
expect(message.data[:refresh_stream]).to be_present
end
end
describe 'when new category has a default auto-close' do
before do
another_category.update!(auto_close_hours: 5)
end
it 'should apply the auto-close timer upon publishing' do
topic
described_class.new.execute(topic_timer_id: topic.public_topic_timer.id)
topic.reload
topic_timer = topic.public_topic_timer
expect(topic.category).to eq(another_category)
expect(topic_timer.status_type).to eq(TopicTimer.types[:close])
expect(topic_timer.execute_at).to be_within(1.second).of(5.hours.from_now)
end
end
end