Commit 15ee88e6 authored by charlie ablett's avatar charlie ablett

Merge branch '245026-fix-epic-assignment' into 'master'

Make sure epic_id param is handled properly

See merge request gitlab-org/gitlab!41604
parents 69e1d6fe 9459111a
...@@ -31,7 +31,8 @@ module EE ...@@ -31,7 +31,8 @@ module EE
def set_epic_param(issue) def set_epic_param(issue)
return unless epic_param_present? return unless epic_param_present?
epic = epic_param || find_epic(issue) epic_id = params.delete(:epic_id)
epic = epic_param || find_epic(issue, epic_id)
unless epic unless epic
params[:epic] = nil params[:epic] = nil
...@@ -45,8 +46,7 @@ module EE ...@@ -45,8 +46,7 @@ module EE
params[:epic] = epic params[:epic] = epic
end end
def find_epic(issue) def find_epic(issue, epic_id)
epic_id = params.delete(:epic_id)
return if epic_id.to_i == 0 return if epic_id.to_i == 0
group = issue.project.group group = issue.project.group
......
...@@ -61,6 +61,31 @@ RSpec.shared_examples 'issue with epic_id parameter' do ...@@ -61,6 +61,31 @@ RSpec.shared_examples 'issue with epic_id parameter' do
end end
end end
context 'when epic param is also present' do
context 'when epic_id belongs to another valid epic' do
let(:other_epic) { create(:epic, group: group) }
let(:params) { { title: 'issue1', epic: epic, epic_id: other_epic.id } }
it 'creates epic issue link based on the epic param' do
issue = execute
expect(issue.reload).to be_persisted
expect(issue.epic).to eq(epic)
end
end
context 'when epic_id is empty' do
let(:params) { { title: 'issue1', epic: epic, epic_id: '' } }
it 'creates epic issue link based on the epic param' do
issue = execute
expect(issue.reload).to be_persisted
expect(issue.epic).to eq(epic)
end
end
end
context 'when a project is from a subgroup of the epic group' do context 'when a project is from a subgroup of the epic group' do
before do before do
subgroup = create(:group, parent: group) subgroup = create(:group, parent: group)
......
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