Commit 9459111a authored by Jarka Košanová's avatar Jarka Košanová

Make sure epic_id param is handled properly

parent 39290fed
......@@ -31,7 +31,8 @@ module EE
def set_epic_param(issue)
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
params[:epic] = nil
......@@ -45,8 +46,7 @@ module EE
params[:epic] = epic
end
def find_epic(issue)
epic_id = params.delete(:epic_id)
def find_epic(issue, epic_id)
return if epic_id.to_i == 0
group = issue.project.group
......
......@@ -61,6 +61,31 @@ RSpec.shared_examples 'issue with epic_id parameter' do
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
before do
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