Commit 18655c28 authored by Alfredo Sumaran's avatar Alfredo Sumaran

Merge branch 'associate-new-issue-with-milestone-issue-boards' into 'master'

Fixes issue not adding with milestone on board with associated milestone

Closes #1934 and gitlab-ce#29612

See merge request !1445
parents 6d769a8d 295597c2
...@@ -26,6 +26,10 @@ export default { ...@@ -26,6 +26,10 @@ export default {
subscribed: true, subscribed: true,
}); });
if (Store.state.currentBoard) {
issue.milestone_id = Store.state.currentBoard.milestone_id;
}
this.list.newIssue(issue) this.list.newIssue(issue)
.then(() => { .then(() => {
// Need this because our jQuery very kindly disables buttons on ALL form submissions // Need this because our jQuery very kindly disables buttons on ALL form submissions
......
...@@ -35,6 +35,7 @@ require('./lists_dropdown'); ...@@ -35,6 +35,7 @@ require('./lists_dropdown');
// Post the data to the backend // Post the data to the backend
gl.boardService.bulkUpdate(issueIds, { gl.boardService.bulkUpdate(issueIds, {
add_label_ids: [list.label.id], add_label_ids: [list.label.id],
milestone_id: this.state.currentBoard.milestone_id,
}).catch(() => { }).catch(() => {
new Flash('Failed to update issues, please try again.', 'alert'); new Flash('Failed to update issues, please try again.', 'alert');
......
...@@ -17,6 +17,7 @@ class ListIssue { ...@@ -17,6 +17,7 @@ class ListIssue {
this.selected = false; this.selected = false;
this.assignee = false; this.assignee = false;
this.position = obj.relative_position || Infinity; this.position = obj.relative_position || Infinity;
this.milestone_id = obj.milestone_id;
if (obj.assignee) { if (obj.assignee) {
this.assignee = new ListUser(obj.assignee); this.assignee = new ListUser(obj.assignee);
......
...@@ -97,6 +97,7 @@ class List { ...@@ -97,6 +97,7 @@ class List {
.then((resp) => { .then((resp) => {
const data = resp.json(); const data = resp.json();
issue.id = data.iid; issue.id = data.iid;
issue.milestone = data.milestone;
}); });
} }
......
...@@ -74,7 +74,7 @@ module Projects ...@@ -74,7 +74,7 @@ module Projects
end end
def issue_params def issue_params
params.require(:issue).permit(:title).merge(board_id: params[:board_id], list_id: params[:list_id], request: request) params.require(:issue).permit(:title, :milestone_id).merge(board_id: params[:board_id], list_id: params[:list_id], request: request)
end end
def serialize_as_json(resource) def serialize_as_json(resource)
......
...@@ -112,6 +112,53 @@ describe 'Board with milestone', :feature, :js do ...@@ -112,6 +112,53 @@ describe 'Board with milestone', :feature, :js do
end end
end end
context 'new issues' do
let(:label) { create(:label, project: project) }
let!(:list1) { create(:list, board: board, label: label, position: 0) }
let!(:board) { create(:board, project: project, milestone: milestone) }
let!(:issue) { create(:issue, project: project) }
before do
visit namespace_project_boards_path(project.namespace, project)
end
it 'creates new issue with boards milestone' do
wait_for_vue_resource
page.within(first('.board')) do
find('.btn-default').click
find('.form-control').set('testing new issue with milestone')
click_button('Submit issue')
wait_for_vue_resource
click_link('testing new issue with milestone')
end
expect(page).to have_content(milestone.title)
end
it 'updates issue with milestone from add issues modal' do
wait_for_vue_resource
click_button 'Add issues'
page.within('.add-issues-modal') do
expect(page).to have_selector('.card', count: 1)
first('.card').click
click_button 'Add 1 issue'
end
click_link(issue.title)
expect(page).to have_content(milestone.title)
end
end
def create_board_with_milestone def create_board_with_milestone
page.within '#js-multiple-boards-switcher' do page.within '#js-multiple-boards-switcher' do
find('.dropdown-menu-toggle').click find('.dropdown-menu-toggle').click
......
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