Commit 5764dcb7 authored by Jarka Košanová's avatar Jarka Košanová

Fix parsing epic_id id type param

parent f6e2ac05
...@@ -16,6 +16,12 @@ module EE ...@@ -16,6 +16,12 @@ module EE
required: false, required: false,
description: 'The ID of the parent epic. NULL when removing the association' description: 'The ID of the parent epic. NULL when removing the association'
end end
def resolve(project_path:, iid:, **args)
args[:epic_id] = ::GitlabSchema.parse_gid(args[:epic_id], expected_type: ::Epic).model_id if args[:epic_id]
super
end
end end
end end
end end
......
...@@ -15,7 +15,7 @@ RSpec.describe Mutations::Issues::Update do ...@@ -15,7 +15,7 @@ RSpec.describe Mutations::Issues::Update do
let_it_be(:issue) { create(:issue, project: project) } let_it_be(:issue) { create(:issue, project: project) }
let_it_be(:epic) { create(:epic, group: group) } let_it_be(:epic) { create(:epic, group: group) }
let(:epic_id) { epic.id } let(:epic_id) { epic.to_global_id.to_s }
let(:params) { { project_path: project.full_path, iid: issue.iid, epic_id: epic_id } } let(:params) { { project_path: project.full_path, iid: issue.iid, epic_id: epic_id } }
let(:mutated_issue) { subject[:issue] } let(:mutated_issue) { subject[:issue] }
let(:mutation) { described_class.new(object: nil, context: { current_user: user }, field: nil) } let(:mutation) { described_class.new(object: nil, context: { current_user: user }, field: nil) }
...@@ -48,14 +48,26 @@ RSpec.describe Mutations::Issues::Update do ...@@ -48,14 +48,26 @@ RSpec.describe Mutations::Issues::Update do
context 'when a valid epic is given' do context 'when a valid epic is given' do
it 'updates the epic' do it 'updates the epic' do
expect { subject }.to change { issue.reload.epic }.from(nil).to(epic)
end
it 'returns the updated issue' do
expect(mutated_issue.epic).to eq(epic) expect(mutated_issue.epic).to eq(epic)
end end
end end
context 'when nil epic is given' do context 'when nil epic is given' do
before do
issue.update!(epic: epic)
end
let(:epic_id) { nil } let(:epic_id) { nil }
it 'set the epic to nil' do it 'set the epic to nil' do
expect { subject }.to change { issue.reload.epic }.from(epic).to(nil)
end
it 'returns the updated issue' do
expect(mutated_issue.epic).to be_nil expect(mutated_issue.epic).to be_nil
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