Commit b7c54d3b authored by Michael Kozono's avatar Michael Kozono

Merge branch 'issue_222462' into 'master'

Fix creating/updating issues with epic_iid parameter on API

See merge request gitlab-org/gitlab!34641
parents 53be6217 6f899c13
---
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,6 +254,20 @@ RSpec.describe API::Issues, :mailer do
group.add_owner(user)
end
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
......@@ -261,6 +275,7 @@ RSpec.describe API::Issues, :mailer do
expect(json_response['epic_iid']).to eq(epic.iid)
end
end
end
context 'when user can not edit epics' 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