Commit 6f899c13 authored by Felipe Artur's avatar Felipe Artur Committed by Michael Kozono

Fix creating/updating issues with epic_iid parameter on API

Fix API request timeout when creating/updating issues using API
parent da918859
---
title: Fix creating/updating issues with epic_iid parameter on API
merge_request: 34641
author:
type: fixed
......@@ -15,8 +15,13 @@ module EE
iid = params.delete(:epic_iid)
if iid.present?
epic = EpicsFinder.new(current_user, group_id: group.id, iids: [iid]).first
not_found!('Epic') unless epic
group_id = user_project&.group&.id
raise_epic_not_found! unless group_id
epic = EpicsFinder.new(current_user, group_id: group_id).find_by(iid: iid) # rubocop: disable CodeReuse/ActiveRecord
raise_epic_not_found! unless epic
params[:epic_id] = epic.id
end
......@@ -24,6 +29,10 @@ module EE
super
end
def raise_epic_not_found!
not_found!('Epic')
end
end
end
end
......
......@@ -254,11 +254,26 @@ RSpec.describe API::Issues, :mailer do
group.add_owner(user)
end
it 'sets epic on issue' do
request
context 'with epic_id parameter' do
let(:params) { { title: 'issue with epic', epic_id: epic.id } }
it 'sets epic on issue' do
request
expect(response).to have_gitlab_http_status(:success)
expect(json_response['epic_iid']).to eq(epic.iid)
end
end
context 'with deprecated epic_iid parameter' do
let(:params) { { title: 'issue with epic', epic_iid: epic.iid } }
it 'sets epic on issue' do
request
expect(response).to have_gitlab_http_status(:success)
expect(json_response['epic_iid']).to eq(epic.iid)
expect(response).to have_gitlab_http_status(:success)
expect(json_response['epic_iid']).to eq(epic.iid)
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