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
5d54f74d
Commit
5d54f74d
authored
Apr 09, 2021
by
Sean Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add URLs to oncall schedule entity
- Add specs for entity
parent
a1f74822
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
62 additions
and
7 deletions
+62
-7
ee/app/models/ee/members_preloader.rb
ee/app/models/ee/members_preloader.rb
+3
-2
ee/app/models/incident_management/oncall_schedule.rb
ee/app/models/incident_management/oncall_schedule.rb
+1
-3
ee/app/serializers/incident_management/oncall_schedule_entity.rb
...serializers/incident_management/oncall_schedule_entity.rb
+9
-0
ee/spec/fixtures/api/schemas/entities/member_user.json
ee/spec/fixtures/api/schemas/entities/member_user.json
+23
-0
ee/spec/models/ee/user_spec.rb
ee/spec/models/ee/user_spec.rb
+3
-0
ee/spec/serializers/incident_management/oncall_schedule_entity_spec.rb
...lizers/incident_management/oncall_schedule_entity_spec.rb
+22
-0
spec/fixtures/api/schemas/entities/member_user.json
spec/fixtures/api/schemas/entities/member_user.json
+1
-2
No files found.
ee/app/models/ee/members_preloader.rb
View file @
5d54f74d
...
...
@@ -8,8 +8,9 @@ module EE
def
preload_all
super
ActiveRecord
::
Associations
::
Preloader
.
new
.
preload
(
members
.
map
(
&
:user
),
group_saml_identities: :saml_provider
)
ActiveRecord
::
Associations
::
Preloader
.
new
.
preload
(
members
.
map
(
&
:user
),
oncall_participants:
{
rotation: :schedule
})
users
=
members
.
map
(
&
:user
)
ActiveRecord
::
Associations
::
Preloader
.
new
.
preload
(
users
,
group_saml_identities: :saml_provider
)
ActiveRecord
::
Associations
::
Preloader
.
new
.
preload
(
users
,
oncall_participants:
{
rotation: :schedule
})
end
end
end
ee/app/models/incident_management/oncall_schedule.rb
View file @
5d54f74d
...
...
@@ -22,9 +22,7 @@ module IncidentManagement
scope
:for_iid
,
->
(
iid
)
{
where
(
iid:
iid
)
}
def
project_name
project
.
name
end
delegate
:name
,
to: :project
,
prefix:
true
private
...
...
ee/app/serializers/incident_management/oncall_schedule_entity.rb
View file @
5d54f74d
...
...
@@ -2,7 +2,16 @@
module
IncidentManagement
class
OncallScheduleEntity
<
Grape
::
Entity
include
Gitlab
::
Routing
expose
:name
expose
:project_name
expose
:schedule_url
do
|
schedule
|
project_incident_management_oncall_schedules_url
(
schedule
.
project
)
end
expose
:project_url
do
|
schedule
|
project_url
(
schedule
.
project
)
end
end
end
ee/spec/fixtures/api/schemas/entities/member_user.json
0 → 100644
View file @
5d54f74d
{
"type"
:
"object"
,
"allOf"
:
[
{
"$ref"
:
"../../../../../../spec/fixtures/api/schemas/entities/member_user.json"
},
{
"required"
:
[
"oncall_schedules"
],
"properties"
:
{
"oncall_schedules"
:
{
"type"
:
"array"
,
"items"
:
{
"type"
:
"object"
,
"properties"
:
{
"name"
:
{
"type"
:
"string"
},
"project_name"
:
{
"type"
:
"string"
}
}
}
}
}
}
]
}
ee/spec/models/ee/user_spec.rb
View file @
5d54f74d
...
...
@@ -28,6 +28,9 @@ RSpec.describe User do
it
{
is_expected
.
to
have_many
(
:board_preferences
)
}
it
{
is_expected
.
to
have_many
(
:boards_epic_user_preferences
).
class_name
(
'Boards::EpicUserPreference'
)
}
it
{
is_expected
.
to
have_many
(
:user_permission_export_uploads
)
}
it
{
is_expected
.
to
have_many
(
:oncall_participants
).
class_name
(
'IncidentManagement::OncallParticipant'
)
}
it
{
is_expected
.
to
have_many
(
:oncall_rotations
).
class_name
(
'IncidentManagement::OncallRotation'
).
through
(
:oncall_participants
)
}
it
{
is_expected
.
to
have_many
(
:oncall_schedules
).
class_name
(
'IncidentManagement::OncallSchedule'
).
through
(
:oncall_rotations
)
}
end
describe
'nested attributes'
do
...
...
ee/spec/serializers/incident_management/oncall_schedule_entity_spec.rb
0 → 100644
View file @
5d54f74d
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
IncidentManagement
::
OncallScheduleEntity
do
let
(
:schedule
)
{
create
(
:incident_management_oncall_schedule
)
}
let
(
:schedule_url
)
{
Gitlab
::
Routing
.
url_helpers
.
project_incident_management_oncall_schedules_url
(
schedule
.
project
)
}
let
(
:project_url
)
{
Gitlab
::
Routing
.
url_helpers
.
project_url
(
schedule
.
project
)
}
subject
{
described_class
.
new
(
schedule
)
}
describe
'.as_json'
do
it
'includes oncall schdule attributes'
do
attributes
=
subject
.
as_json
expect
(
attributes
[
:name
]).
to
eq
(
schedule
.
name
)
expect
(
attributes
[
:project_name
]).
to
eq
(
schedule
.
project
.
name
)
expect
(
attributes
[
:schedule_url
]).
to
eq
(
schedule_url
)
expect
(
attributes
[
:project_url
]).
to
eq
(
project_url
)
end
end
end
spec/fixtures/api/schemas/entities/member_user.json
View file @
5d54f74d
...
...
@@ -18,6 +18,5 @@
},
"additionalProperties"
:
false
}
},
"additionalProperties"
:
false
}
}
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