Skip to content

A platform for community discussion. Free, open, simple.

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

Martin Brennane0f0fe562429
diff --git a/app/assets/javascripts/discourse/app/controllers/edit-topic-timer.js b/app/assets/javascripts/discourse/app/controllers/edit-topic-timer.js
index 01c0286b134..2cfbdc74c32 100644
--- a/app/assets/javascripts/discourse/app/controllers/edit-topic-timer.js
+++ b/app/assets/javascripts/discourse/app/controllers/edit-topic-timer.js
@@ -178,8 +178,8 @@ export default Controller.extend(ModalFunctionality, {
return;
}
- // cannot be more than 2 years
- if (this.get("topicTimer.duration_minutes") > 2 * 365 * 1440) {
+ // cannot be more than 20 years
+ if (this.get("topicTimer.duration_minutes") > 20 * 365 * 1440) {
this.flash(
I18n.t("topic.topic_status_update.max_duration"),
"alert-error"
diff --git a/app/models/topic_timer.rb b/app/models/topic_timer.rb
index d80e8012788..2227004d566 100644
--- a/app/models/topic_timer.rb
+++ b/app/models/topic_timer.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class TopicTimer < ActiveRecord::Base
- MAX_DURATION_MINUTES = 2.years.to_i / 60
+ MAX_DURATION_MINUTES = 20.years.to_i / 60
self.ignored_columns = [
"duration" # TODO(2021-06-01): remove
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 3b776c522a1..b0ebd9d2649 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -2446,7 +2446,7 @@ en:
when: "When:"
time_frame_required: "Please select a time frame"
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:
none: "Select a timeframe"
now: "Now"
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 93ccfbd0b9e..142172c672f 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -618,7 +618,7 @@ en:
in_the_past: "must be in the future."
duration_minutes:
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:
attributes:
value:
diff --git a/spec/models/topic_timer_spec.rb b/spec/models/topic_timer_spec.rb
index 463b2bda76b..cff5316d5cc 100644
--- a/spec/models/topic_timer_spec.rb
+++ b/spec/models/topic_timer_spec.rb
@@ -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.")
end
- it "does not allow crazy big durations (2 years in minutes)" do
- topic_timer.duration_minutes = 3.years.to_i / 60
+ it "does not allow crazy big durations (20 years in minutes)" do
+ topic_timer.duration_minutes = 21.years.to_i / 60
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