Commit 7901fa47 authored by Sean Arnold's avatar Sean Arnold

Update params to allow setting values to nil

Add specs for missing cases
parent 783126ea
...@@ -42,7 +42,7 @@ module Mutations ...@@ -42,7 +42,7 @@ module Mutations
params[:participants] = find_participants(participants) params[:participants] = find_participants(participants)
params[:starts_at] = parse_datetime(schedule, args[:starts_at]) if args[:starts_at] params[:starts_at] = parse_datetime(schedule, args[:starts_at]) if args[:starts_at]
params[:ends_at] = parse_datetime(schedule, args[:ends_at]) if args[:ends_at] params[:ends_at] = parse_datetime(schedule, args[:ends_at]) if args.key?(:ends_at)
if args[:rotation_length] if args[:rotation_length]
params.merge!( params.merge!(
...@@ -51,7 +51,7 @@ module Mutations ...@@ -51,7 +51,7 @@ module Mutations
) )
end end
if args[:active_period].present? if args.key?(:active_period)
active_period_start, active_period_end = active_period_times(args) active_period_start, active_period_end = active_period_times(args)
params.merge!( params.merge!(
active_period_start: active_period_start, active_period_start: active_period_start,
......
...@@ -85,6 +85,10 @@ RSpec.describe Mutations::IncidentManagement::OncallRotation::Update do ...@@ -85,6 +85,10 @@ RSpec.describe Mutations::IncidentManagement::OncallRotation::Update do
context 'when endsAt is nil' do context 'when endsAt is nil' do
let(:ends_at) { nil } let(:ends_at) { nil }
before do
rotation.update!(ends_at: Time.current)
end
it 'returns the on-call rotation with no errors' do it 'returns the on-call rotation with no errors' do
expect(resolve[:oncall_rotation].ends_at).to be_nil expect(resolve[:oncall_rotation].ends_at).to be_nil
expect(resolve[:errors]).to be_empty expect(resolve[:errors]).to be_empty
...@@ -165,6 +169,21 @@ RSpec.describe Mutations::IncidentManagement::OncallRotation::Update do ...@@ -165,6 +169,21 @@ RSpec.describe Mutations::IncidentManagement::OncallRotation::Update do
end end
end end
context 'removing active period' do
before do
rotation.update!(active_period_start: "08:00", active_period_end: "17:00")
args.merge!(active_period: nil)
end
it 'removes the active period' do
expect(resolve[:errors]).to be_empty
expect(rotation.reload.active_period_start).to eq(nil)
expect(rotation.active_period_end).to eq(nil)
end
end
describe 'error cases' do describe 'error cases' do
context 'user cannot be found' do context 'user cannot be found' do
before do before do
......
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