mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Validate duration minutes values for topic timer (#12040)
Add server and client side validations to ensure topic timer durations cannot exceed 2 years and cannot be less than or equal to 0.
This commit is contained in:
@@ -23,6 +23,20 @@ RSpec.describe TopicTimer, type: :model do
|
||||
topic_timer.update!(execute_at: 1.minute.ago, created_at: 10.minutes.ago)
|
||||
expect(TopicTimer.pending_timers.pluck(:id)).to include(topic_timer.id)
|
||||
end
|
||||
|
||||
describe "duration values" do
|
||||
it "does not allow durations <= 0" do
|
||||
topic_timer.duration_minutes = -1
|
||||
topic_timer.save
|
||||
expect(topic_timer.errors.full_messages.first).to include("Duration minutes must be greater than 0.")
|
||||
end
|
||||
|
||||
it "does not allow crazy big durations (2 years in minutes)" do
|
||||
topic_timer.duration_minutes = 3.years.to_i / 60
|
||||
topic_timer.save
|
||||
expect(topic_timer.errors.full_messages.first).to include("Duration minutes cannot be more than 2 years.")
|
||||
end
|
||||
end
|
||||
end
|
||||
describe '#status_type' do
|
||||
it 'should ensure that only one active public topic status update exists' do
|
||||
|
||||
Reference in New Issue
Block a user