mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
FEATURE: Automatically disable slow mode. (#11461)
Staff and TL4 users can decide the slow mode duration. We'll internally set a topic timer to disable it.
This commit is contained in:
@ -3227,6 +3227,54 @@ RSpec.describe TopicsController do
|
||||
expect(topic.slow_mode_seconds).to eq(3600)
|
||||
end
|
||||
end
|
||||
|
||||
context 'auto-disable slow mode' do
|
||||
before { sign_in(admin) }
|
||||
|
||||
let(:timestamp) { 1.week.from_now.to_formatted_s(:iso8601) }
|
||||
|
||||
it 'sets a topic timer to clear the slow mode automatically' do
|
||||
put "/t/#{topic.id}/slow_mode.json", params: {
|
||||
seconds: '3600', enabled_until: timestamp
|
||||
}
|
||||
|
||||
created_timer = TopicTimer.find_by(topic: topic)
|
||||
execute_at = created_timer.execute_at.to_formatted_s(:iso8601)
|
||||
|
||||
expect(execute_at).to eq(timestamp)
|
||||
end
|
||||
|
||||
it 'deletes the topic timer' do
|
||||
put "/t/#{topic.id}/slow_mode.json", params: {
|
||||
seconds: '3600', enabled_until: timestamp
|
||||
}
|
||||
|
||||
put "/t/#{topic.id}/slow_mode.json", params: {
|
||||
seconds: '0', enabled_until: timestamp
|
||||
}
|
||||
|
||||
created_timer = TopicTimer.find_by(topic: topic)
|
||||
|
||||
expect(created_timer).to be_nil
|
||||
end
|
||||
|
||||
it 'updates the existing timer' do
|
||||
put "/t/#{topic.id}/slow_mode.json", params: {
|
||||
seconds: '3600', enabled_until: timestamp
|
||||
}
|
||||
|
||||
updated_timestamp = 1.hour.from_now.to_formatted_s(:iso8601)
|
||||
|
||||
put "/t/#{topic.id}/slow_mode.json", params: {
|
||||
seconds: '3600', enabled_until: updated_timestamp
|
||||
}
|
||||
|
||||
created_timer = TopicTimer.find_by(topic: topic)
|
||||
execute_at = created_timer.execute_at.to_formatted_s(:iso8601)
|
||||
|
||||
expect(execute_at).to eq(updated_timestamp)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#invite' do
|
||||
|
Reference in New Issue
Block a user