Commit 7560e6ae authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'fix_issue_from_milestone' into 'master'

Fix issue from milestone

See merge request !8895
parents 39e525a0 9a24db12
...@@ -44,7 +44,15 @@ module Issues ...@@ -44,7 +44,15 @@ module Issues
end end
def issue_params 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 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 ...@@ -120,11 +120,20 @@ describe Issues::BuildService, services: true do
end end
describe '#execute' do describe '#execute' do
let(:milestone) { create(:milestone, project: project) }
it 'builds a new issues with given params' do 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.title).to eq('Issue #1')
expect(issue.description).to eq('Issue description') expect(issue.description).to eq('Issue description')
expect(issue.milestone).to eq(milestone)
end end
end end
end end
...@@ -46,6 +46,7 @@ describe Issues::CreateService, services: true do ...@@ -46,6 +46,7 @@ describe Issues::CreateService, services: true do
expect(issue).to be_persisted expect(issue).to be_persisted
expect(issue.title).to eq('Awesome issue') expect(issue.title).to eq('Awesome issue')
expect(issue.description).to eq('please fix')
expect(issue.assignee).to be_nil expect(issue.assignee).to be_nil
expect(issue.labels).to be_empty expect(issue.labels).to be_empty
expect(issue.milestone).to be_nil expect(issue.milestone).to be_nil
......
...@@ -58,7 +58,7 @@ shared_examples 'new issuable record that supports slash commands' do ...@@ -58,7 +58,7 @@ shared_examples 'new issuable record that supports slash commands' do
let(:example_params) do let(:example_params) do
{ {
assignee: create(:user), assignee: create(:user),
milestone_id: double(:milestone), milestone_id: 1,
description: %(/assign @#{assignee.username}\n/milestone %"#{milestone.name}") description: %(/assign @#{assignee.username}\n/milestone %"#{milestone.name}")
} }
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