Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
85f370f9
Commit
85f370f9
authored
Nov 12, 2020
by
Vitali Tatarintev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move OncallSchedule model to EE
Move the model to EE. It's only available for Gitlab Premium.
parent
279cb5d7
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
3 deletions
+53
-3
app/models/project.rb
app/models/project.rb
+0
-1
ee/app/models/ee/project.rb
ee/app/models/ee/project.rb
+2
-0
ee/app/models/incident_management/oncall_schedule.rb
ee/app/models/incident_management/oncall_schedule.rb
+7
-2
ee/spec/factories/incident_management/oncall_schedules.rb
ee/spec/factories/incident_management/oncall_schedules.rb
+0
-0
ee/spec/models/incident_management/oncall_schedule_spec.rb
ee/spec/models/incident_management/oncall_schedule_spec.rb
+42
-0
ee/spec/models/project_spec.rb
ee/spec/models/project_spec.rb
+2
-0
No files found.
app/models/project.rb
View file @
85f370f9
...
...
@@ -273,7 +273,6 @@ 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
...
...
ee/app/models/ee/project.rb
View file @
85f370f9
...
...
@@ -98,6 +98,8 @@ module EE
has_many
:sourced_pipelines
,
class_name:
'Ci::Sources::Project'
,
foreign_key: :source_project_id
has_many
:incident_management_oncall_schedules
,
class_name:
'IncidentManagement::OncallSchedule'
,
inverse_of: :project
scope
:with_shared_runners_limit_enabled
,
->
do
if
::
Ci
::
Runner
.
has_shared_runners_with_non_zero_public_cost?
with_shared_runners
...
...
app/models/incident_management/oncall_schedule.rb
→
ee/
app/models/incident_management/oncall_schedule.rb
View file @
85f370f9
...
...
@@ -9,7 +9,6 @@ module IncidentManagement
NAME_LENGTH
=
200
DESCRIPTION_LENGTH
=
1000
TIMEZONE_LENGTH
=
100
belongs_to
:project
,
inverse_of: :incident_management_oncall_schedules
...
...
@@ -17,6 +16,12 @@ module IncidentManagement
validates
:name
,
presence:
true
,
length:
{
maximum:
NAME_LENGTH
}
validates
:description
,
length:
{
maximum:
DESCRIPTION_LENGTH
}
validates
:timezone
,
presence:
true
,
length:
{
maximum:
TIMEZONE_LENGTH
}
validates
:timezone
,
presence:
true
,
inclusion:
{
in: :timezones
}
private
def
timezones
@timezones
||=
ActiveSupport
::
TimeZone
.
all
.
map
{
|
tz
|
tz
.
tzinfo
.
identifier
}
end
end
end
spec/factories/incident_management/oncall_schedules.rb
→
ee/
spec/factories/incident_management/oncall_schedules.rb
View file @
85f370f9
File moved
spec/models/incident_management/oncall_schedule_spec.rb
→
ee/
spec/models/incident_management/oncall_schedule_spec.rb
View file @
85f370f9
...
...
@@ -10,12 +10,33 @@ RSpec.describe IncidentManagement::OncallSchedule do
end
describe
'.validations'
do
let
(
:timezones
)
{
ActiveSupport
::
TimeZone
.
all
.
map
{
|
tz
|
tz
.
tzinfo
.
identifier
}
}
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
)
}
it
{
is_expected
.
to
validate_inclusion_of
(
:timezone
).
in_array
(
timezones
)
}
context
'when the oncall schedule with the same name exists'
do
before
do
create
(
:incident_management_oncall_schedule
,
project:
project
)
end
it
'has validation errors'
do
expect
(
subject
).
to
be_invalid
expect
(
subject
.
errors
.
full_messages
.
to_sentence
).
to
eq
(
'Name has already been taken'
)
end
end
end
it_behaves_like
'AtomicInternalId'
do
let
(
:internal_id_attribute
)
{
:iid
}
let
(
:instance
)
{
build
(
:incident_management_oncall_schedule
)
}
let
(
:scope
)
{
:project
}
let
(
:scope_attrs
)
{
{
project:
instance
.
project
}
}
let
(
:usage
)
{
:incident_management_oncall_schedules
}
end
end
ee/spec/models/project_spec.rb
View file @
85f370f9
...
...
@@ -51,6 +51,8 @@ RSpec.describe Project do
it
{
is_expected
.
to
have_many
(
:project_aliases
)
}
it
{
is_expected
.
to
have_many
(
:approval_rules
)
}
it
{
is_expected
.
to
have_many
(
:incident_management_oncall_schedules
).
class_name
(
'IncidentManagement::OncallSchedule'
)
}
describe
'approval_rules association'
do
let_it_be
(
:rule
,
reload:
true
)
{
create
(
:approval_project_rule
)
}
let
(
:project
)
{
rule
.
project
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment