OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Add integer validations for recurring meeting intervals
Oliver Güntherb0be0bd2651f
diff --git a/modules/meeting/app/models/recurring_meeting.rb b/modules/meeting/app/models/recurring_meeting.rbindex 094a5d1a006..857f4535b67 100644--- a/modules/meeting/app/models/recurring_meeting.rb+++ b/modules/meeting/app/models/recurring_meeting.rb@@ -8,6 +8,10 @@ class RecurringMeeting < ApplicationRecordvalidates_presence_of :start_time, :title, :frequency, :end_aftervalidates_presence_of :end_date, if: -> { end_after_specific_date? }validates_numericality_of :iterations, if: -> { end_after_iterations? }+ validates_numericality_of :interval,+ only_integer: true,+ greater_than_or_equal_to: 1,+ if: -> { !frequency_working_days? }validate :end_date_constraints,if: -> { end_after_specific_date? }diff --git a/modules/meeting/spec/models/recurring_meeting_spec.rb b/modules/meeting/spec/models/recurring_meeting_spec.rbindex 0f78aa5ca9b..3c6e7f89fb1 100644--- a/modules/meeting/spec/models/recurring_meeting_spec.rb+++ b/modules/meeting/spec/models/recurring_meeting_spec.rb@@ -27,6 +27,34 @@ RSpec.describe RecurringMeeting,endend+ describe "intervals" do+ subject { build(:recurring_meeting) }++ it "validates integer values >= 1" do+ subject.interval = 1+ expect(subject).to be_valid+ expect(subject.errors[:interval]).to be_empty+ end++ it "adds errors for invalid values", :aggregate_failures do+ subject.interval = 0+ expect(subject).not_to be_valid+ expect(subject.errors[:interval]).to include("must be greater than or equal to 1.")++ subject.interval = -1+ expect(subject).not_to be_valid+ expect(subject.errors[:interval]).to include("must be greater than or equal to 1.")++ subject.interval = 0.1+ expect(subject).not_to be_valid+ expect(subject.errors[:interval]).to include("is not an integer.")++ subject.interval = "asdf"+ expect(subject).not_to be_valid+ expect(subject.errors[:interval]).to include("is not a number.")+ end+ end+describe "daily schedule" dosubject dobuild(:recurring_meeting,