Commit 9a24db12 authored by wendy0402's avatar wendy0402

fix issue creation from milestone doesn't assign the milestone

parent edb8ed36
......@@ -44,7 +44,15 @@ module Issues
end
def issue_params
@issue_params ||= issue_params_with_info_from_merge_request.merge(params.slice(:title, :description))
@issue_params ||= issue_params_with_info_from_merge_request.merge(whitelisted_issue_params)
end
def whitelisted_issue_params
if can?(current_user, :admin_issue, project)
params.slice(:title, :description, :milestone_id)
else
params.slice(:title, :description)
end
end
end
end
---
title: fix milestone does not automatically assign when create issue from milestone
merge_request:
author:
......@@ -120,11 +120,20 @@ describe Issues::BuildService, services: true do
end
describe '#execute' do
let(:milestone) { create(:milestone, project: project) }
it 'builds a new issues with given params' do
issue = described_class.new(project, user, title: 'Issue #1', description: 'Issue description').execute
issue = described_class.new(
project,
user,
title: 'Issue #1',
description: 'Issue description',
milestone_id: milestone.id,
).execute
expect(issue.title).to eq('Issue #1')
expect(issue.description).to eq('Issue description')
expect(issue.milestone).to eq(milestone)
end
end
end
......@@ -46,6 +46,7 @@ describe Issues::CreateService, services: true do
expect(issue).to be_persisted
expect(issue.title).to eq('Awesome issue')
expect(issue.description).to eq('please fix')
expect(issue.assignee).to be_nil
expect(issue.labels).to be_empty
expect(issue.milestone).to be_nil
......
......@@ -58,7 +58,7 @@ shared_examples 'new issuable record that supports slash commands' do
let(:example_params) do
{
assignee: create(:user),
milestone_id: double(:milestone),
milestone_id: 1,
description: %(/assign @#{assignee.username}\n/milestone %"#{milestone.name}")
}
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