Commit 838a90fe authored by Sean Arnold's avatar Sean Arnold

Use consistent execution time. Un-null a field

parent 077b9a1d
......@@ -10161,7 +10161,7 @@ Describes an incident management on-call schedule.
| <a id="incidentmanagementoncallscheduledescription"></a>`description` | [`String`](#string) | Description of the on-call schedule. |
| <a id="incidentmanagementoncallscheduleiid"></a>`iid` | [`ID!`](#id) | Internal ID of the on-call schedule. |
| <a id="incidentmanagementoncallschedulename"></a>`name` | [`String!`](#string) | Name of the on-call schedule. |
| <a id="incidentmanagementoncallscheduleoncallusers"></a>`oncallUsers` | [`[UserCore!]!`](#usercore) | |
| <a id="incidentmanagementoncallscheduleoncallusers"></a>`oncallUsers` | [`[UserCore!]`](#usercore) | |
| <a id="incidentmanagementoncallschedulerotations"></a>`rotations` | [`IncidentManagementOncallRotationConnection!`](#incidentmanagementoncallrotationconnection) | On-call rotations for the on-call schedule. (see [Connections](#connections)) |
| <a id="incidentmanagementoncallscheduletimezone"></a>`timezone` | [`String!`](#string) | Time zone of the on-call schedule. |
......
......@@ -18,6 +18,8 @@ module Resolvers
end
def resolve_with_lookahead(**args)
context[:execution_time] = Time.current
apply_lookahead(::IncidentManagement::EscalationPoliciesFinder.new(current_user, project, args).execute)
end
......
......@@ -8,7 +8,9 @@ module Resolvers
type [::Types::UserType], null: true
def resolve
::IncidentManagement::OncallUsersFinder.new(schedule.project, schedule: schedule).execute
oncall_at = context[:execution_time] || Time.current
::IncidentManagement::OncallUsersFinder.new(schedule.project, schedule: schedule, oncall_at: oncall_at).execute
end
end
end
......
......@@ -41,7 +41,7 @@ module Types
field :oncall_users,
[::Types::UserType],
null: false,
null: true,
resolver: ::Resolvers::IncidentManagement::OncallUsersResolver
end
end
......
......@@ -24,6 +24,17 @@ RSpec.describe Resolvers::IncidentManagement::OncallUsersResolver do
expect(schedule.participants.pluck(:user_id)).to include(users.first.id)
end
it 'calls the finder with the execution_time context' do
execution_time = Time.current
context = { current_user: current_user, execution_time: execution_time }
expect(::IncidentManagement::OncallUsersFinder).to receive(:new)
.with(project, hash_including(oncall_at: execution_time))
.and_call_original
resolve_oncall_users({}, context)
end
context 'when an error occurs while finding shifts' do
before do
stub_licensed_features(oncall_schedules: false)
......
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