Commit 1405470c authored by Vitali Tatarintev's avatar Vitali Tatarintev

Create IncidentManagement::OncallSchedule model

The storage for Incident Management on-call schedules
parent 0316d92f
......@@ -15,7 +15,8 @@ module Enums
operations_user_lists: 7,
alert_management_alerts: 8,
sprints: 9, # iterations
design_management_designs: 10
design_management_designs: 10,
incident_management_oncall_schedules: 11
}
end
end
......
# frozen_string_literal: true
module IncidentManagement
class OncallSchedule < ApplicationRecord
self.table_name = 'incident_management_oncall_schedules'
include IidRoutes
include AtomicInternalId
NAME_LENGTH = 200
DESCRIPTION_LENGTH = 1000
TIMEZONE_LENGTH = 100
belongs_to :project, inverse_of: :incident_management_oncall_schedules
has_internal_id :iid, scope: :project
validates :name, presence: true, length: { maximum: NAME_LENGTH }
validates :description, length: { maximum: DESCRIPTION_LENGTH }
validates :timezone, presence: true, length: { maximum: TIMEZONE_LENGTH }
end
end
......@@ -273,6 +273,7 @@ class Project < ApplicationRecord
has_many :alert_management_alerts, class_name: 'AlertManagement::Alert', inverse_of: :project
has_many :alert_management_http_integrations, class_name: 'AlertManagement::HttpIntegration', inverse_of: :project
has_many :incident_management_oncall_schedules, class_name: 'IncidentManagement::OncallSchedule', inverse_of: :project
# Container repositories need to remove data from the container registry,
# which is not managed by the DB. Hence we're still using dependent: :destroy
......
# frozen_string_literal: true
FactoryBot.define do
factory :incident_management_oncall_schedule, class: 'IncidentManagement::OncallSchedule' do
project
name { 'Default On-call Schedule' }
description { 'On-call description' }
timezone { 'Europe/Berlin' }
end
end
......@@ -554,6 +554,7 @@ project:
- terraform_states
- alert_management_http_integrations
- exported_protected_branches
- incident_management_oncall_schedules
award_emoji:
- awardable
- user
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe IncidentManagement::OncallSchedule do
let_it_be(:project) { create(:project) }
describe '.associations' do
it { is_expected.to belong_to(:project) }
end
describe '.validations' do
subject { build(:incident_management_oncall_schedule, project: project) }
it { is_expected.to validate_presence_of(:name) }
it { is_expected.to validate_length_of(:name).is_at_most(200) }
it { is_expected.to validate_length_of(:description).is_at_most(1000) }
it { is_expected.to validate_presence_of(:timezone) }
it { is_expected.to validate_length_of(:timezone).is_at_most(100) }
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment