Commit b419173b authored by Sean Arnold's avatar Sean Arnold

Fix bugs with updating nested params

- Fix styling
parent aec25187
......@@ -54,7 +54,19 @@ module Mutations
def edit_service_params(schedule, participants, args)
parsed_service_params = parsed_params(schedule, participants, args)
args.slice(:name).merge(parsed_service_params.slice(*args.keys))
args_to_update = parsed_service_params.slice(*args.keys)
if args[:rotation_length]
args_to_update[:length] = parsed_service_params[:length]
args_to_update[:length_unit] = parsed_service_params[:length_unit]
end
if args[:active_period]
args_to_update[:active_period_start] = parsed_service_params[:active_period_start]
args_to_update[:active_period_end] = parsed_service_params[:active_period_end]
end
args.slice(:name).merge(args_to_update)
end
def find_object(id:)
......
......@@ -38,9 +38,13 @@ RSpec.describe Mutations::IncidentManagement::OncallRotation::Update do
context 'when OncallRotation::UpdateService responds with success' do
it 'returns the on-call rotation with no errors' do
expect(resolve).to match(
oncall_rotation: ::IncidentManagement::OncallRotation.last!,
oncall_rotation: rotation.reload,
errors: be_empty
)
expect(rotation).to have_attributes(args.except(:participants, :rotation_length))
expect(rotation.length).to eq(args[:rotation_length][:length])
expect(rotation.length_unit).to eq(IncidentManagement::OncallRotation.length_units.key(args[:rotation_length][:unit]))
end
it 'adds the participant to the rotation' do
......
......@@ -109,7 +109,7 @@ RSpec.describe 'getting Incident Management on-call shifts' do
context 'errors' do
context 'user cannot be found' do
let(:params) { { participants: [ { username: 'unknown' }] } }
let(:params) { { participants: [{ username: 'unknown' }] } }
it 'raises an error' do
resolve
......@@ -129,7 +129,7 @@ RSpec.describe 'getting Incident Management on-call shifts' do
{
username: participant.user.username,
colorWeight: 'WEIGHT_500',
colorPalette: 'BLUE',
colorPalette: 'BLUE'
}
end
......@@ -138,7 +138,7 @@ RSpec.describe 'getting Incident Management on-call shifts' do
{
username: participant.user.username,
colorWeight: "WEIGHT_#{participant.color_weight}",
colorPalette: participant.color_palette.upcase,
colorPalette: participant.color_palette.upcase
}
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