FIX: Bump max topic timer duration to 20 years (#12107)

This way it has some sort of cap, even if it seems pretty
high, and we don't have to worry about requests for increasing
it from 2 to 5 to 10 etc.
This commit is contained in:
Martin Brennan 2021-02-18 11:52:30 +10:00 committed by GitHub
parent 7829558c6d
commit e0f0fe5624
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 8 deletions

View File

@ -178,8 +178,8 @@ export default Controller.extend(ModalFunctionality, {
return; return;
} }
// cannot be more than 2 years // cannot be more than 20 years
if (this.get("topicTimer.duration_minutes") > 2 * 365 * 1440) { if (this.get("topicTimer.duration_minutes") > 20 * 365 * 1440) {
this.flash( this.flash(
I18n.t("topic.topic_status_update.max_duration"), I18n.t("topic.topic_status_update.max_duration"),
"alert-error" "alert-error"

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
class TopicTimer < ActiveRecord::Base class TopicTimer < ActiveRecord::Base
MAX_DURATION_MINUTES = 2.years.to_i / 60 MAX_DURATION_MINUTES = 20.years.to_i / 60
self.ignored_columns = [ self.ignored_columns = [
"duration" # TODO(2021-06-01): remove "duration" # TODO(2021-06-01): remove

View File

@ -2446,7 +2446,7 @@ en:
when: "When:" when: "When:"
time_frame_required: "Please select a time frame" time_frame_required: "Please select a time frame"
min_duration: "Duration must be greater than 0" min_duration: "Duration must be greater than 0"
max_duration: "Duration must be less than 2 years" max_duration: "Duration must be less than 20 years"
auto_update_input: auto_update_input:
none: "Select a timeframe" none: "Select a timeframe"
now: "Now" now: "Now"

View File

@ -618,7 +618,7 @@ en:
in_the_past: "must be in the future." in_the_past: "must be in the future."
duration_minutes: duration_minutes:
cannot_be_zero: "must be greater than 0." cannot_be_zero: "must be greater than 0."
exceeds_maximum: "cannot be more than 2 years." exceeds_maximum: "cannot be more than 20 years."
translation_overrides: translation_overrides:
attributes: attributes:
value: value:

View File

@ -31,10 +31,10 @@ RSpec.describe TopicTimer, type: :model do
expect(topic_timer.errors.full_messages.first).to include("Duration minutes must be greater than 0.") expect(topic_timer.errors.full_messages.first).to include("Duration minutes must be greater than 0.")
end end
it "does not allow crazy big durations (2 years in minutes)" do it "does not allow crazy big durations (20 years in minutes)" do
topic_timer.duration_minutes = 3.years.to_i / 60 topic_timer.duration_minutes = 21.years.to_i / 60
topic_timer.save topic_timer.save
expect(topic_timer.errors.full_messages.first).to include("Duration minutes cannot be more than 2 years.") expect(topic_timer.errors.full_messages.first).to include("Duration minutes cannot be more than 20 years.")
end end
end end
end end