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 ...@@ -54,7 +54,19 @@ module Mutations
def edit_service_params(schedule, participants, args) def edit_service_params(schedule, participants, args)
parsed_service_params = parsed_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 end
def find_object(id:) def find_object(id:)
......
...@@ -38,9 +38,13 @@ RSpec.describe Mutations::IncidentManagement::OncallRotation::Update do ...@@ -38,9 +38,13 @@ RSpec.describe Mutations::IncidentManagement::OncallRotation::Update do
context 'when OncallRotation::UpdateService responds with success' do context 'when OncallRotation::UpdateService responds with success' do
it 'returns the on-call rotation with no errors' do it 'returns the on-call rotation with no errors' do
expect(resolve).to match( expect(resolve).to match(
oncall_rotation: ::IncidentManagement::OncallRotation.last!, oncall_rotation: rotation.reload,
errors: be_empty 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 end
it 'adds the participant to the rotation' do it 'adds the participant to the rotation' do
......
...@@ -48,7 +48,7 @@ RSpec.describe 'getting Incident Management on-call shifts' do ...@@ -48,7 +48,7 @@ RSpec.describe 'getting Incident Management on-call shifts' do
subject(:resolve) { post_graphql_mutation(mutation, current_user: current_user) } subject(:resolve) { post_graphql_mutation(mutation, current_user: current_user) }
def mutation_response def mutation_response
graphql_mutation_response(:oncall_rotation_update) graphql_mutation_response(:oncall_rotation_update)
end end
context 'updating name only' do context 'updating name only' do
...@@ -109,7 +109,7 @@ RSpec.describe 'getting Incident Management on-call shifts' do ...@@ -109,7 +109,7 @@ RSpec.describe 'getting Incident Management on-call shifts' do
context 'errors' do context 'errors' do
context 'user cannot be found' do context 'user cannot be found' do
let(:params) { { participants: [ { username: 'unknown' }] } } let(:params) { { participants: [{ username: 'unknown' }] } }
it 'raises an error' do it 'raises an error' do
resolve resolve
...@@ -129,7 +129,7 @@ RSpec.describe 'getting Incident Management on-call shifts' do ...@@ -129,7 +129,7 @@ RSpec.describe 'getting Incident Management on-call shifts' do
{ {
username: participant.user.username, username: participant.user.username,
colorWeight: 'WEIGHT_500', colorWeight: 'WEIGHT_500',
colorPalette: 'BLUE', colorPalette: 'BLUE'
} }
end end
...@@ -138,7 +138,7 @@ RSpec.describe 'getting Incident Management on-call shifts' do ...@@ -138,7 +138,7 @@ RSpec.describe 'getting Incident Management on-call shifts' do
{ {
username: participant.user.username, username: participant.user.username,
colorWeight: "WEIGHT_#{participant.color_weight}", colorWeight: "WEIGHT_#{participant.color_weight}",
colorPalette: participant.color_palette.upcase, colorPalette: participant.color_palette.upcase
} }
end end
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