diff --git a/app/controllers/projects/board_issues_controller.rb b/app/controllers/projects/board_issues_controller.rb index aededeb8c0a..c1814fb1191 100644 --- a/app/controllers/projects/board_issues_controller.rb +++ b/app/controllers/projects/board_issues_controller.rb @@ -43,7 +43,7 @@ class Projects::BoardIssuesController < Projects::ApplicationController end def move_params - params.require(:issue).permit(:from, :to).merge(id: params[:id]) + params.permit(:id, :from_list_id, :to_list_id) end def record_not_found(exception) diff --git a/app/services/boards/issues/move_service.rb b/app/services/boards/issues/move_service.rb index 381bd95c837..7455314450b 100644 --- a/app/services/boards/issues/move_service.rb +++ b/app/services/boards/issues/move_service.rb @@ -23,11 +23,11 @@ module Boards end def moving_from - @moving_from ||= board.lists.find_by(id: params[:from]) + @moving_from ||= board.lists.find_by(id: params[:from_list_id]) end def moving_to - @moving_to ||= board.lists.find_by(id: params[:to]) + @moving_to ||= board.lists.find_by(id: params[:to_list_id]) end def close_service diff --git a/spec/controllers/projects/board_issues_controller_spec.rb b/spec/controllers/projects/board_issues_controller_spec.rb index 6ec3a1b8cfc..a23f0fdf9c5 100644 --- a/spec/controllers/projects/board_issues_controller_spec.rb +++ b/spec/controllers/projects/board_issues_controller_spec.rb @@ -64,13 +64,13 @@ describe Projects::BoardIssuesController do context 'with valid params' do it 'returns a successful 200 response' do - move user: user, issue: issue, from: list1.id, to: list2.id + move user: user, issue: issue, from_list_id: list1.id, to_list_id: list2.id expect(response).to have_http_status(200) end it 'moves issue to the desired list' do - move user: user, issue: issue, from: list1.id, to: list2.id + move user: user, issue: issue, from_list_id: list1.id, to_list_id: list2.id expect(issue.reload.labels).to contain_exactly(development) end @@ -78,13 +78,13 @@ describe Projects::BoardIssuesController do context 'with invalid params' do it 'returns a unprocessable entity 422 response for invalid lists' do - move user: user, issue: issue, from: nil, to: nil + move user: user, issue: issue, from_list_id: nil, to_list_id: nil expect(response).to have_http_status(422) end it 'returns a not found 404 response for invalid issue id' do - move user: user, issue: 999, from: list1.id, to: list2.id + move user: user, issue: 999, from_list_id: list1.id, to_list_id: list2.id expect(response).to have_http_status(404) end @@ -98,19 +98,20 @@ describe Projects::BoardIssuesController do end it 'returns a successful 403 response' do - move user: guest, issue: issue, from: list1.id, to: list2.id + move user: guest, issue: issue, from_list_id: list1.id, to_list_id: list2.id expect(response).to have_http_status(403) end end - def move(user:, issue:, from:, to:) + def move(user:, issue:, from_list_id:, to_list_id:) sign_in(user) patch :update, namespace_id: project.namespace.to_param, project_id: project.to_param, id: issue.to_param, - issue: { from: from, to: to }, + from_list_id: from_list_id, + to_list_id: to_list_id, format: :json end end diff --git a/spec/services/boards/issues/move_service_spec.rb b/spec/services/boards/issues/move_service_spec.rb index ca03ec2d904..a60f5a9c202 100644 --- a/spec/services/boards/issues/move_service_spec.rb +++ b/spec/services/boards/issues/move_service_spec.rb @@ -22,7 +22,7 @@ describe Boards::Issues::MoveService, services: true do context 'when moving from backlog' do it 'adds the label of the list it goes to' do issue = create(:labeled_issue, project: project, labels: [bug]) - params = { id: issue.iid, from: backlog.id, to: list1.id } + params = { id: issue.iid, from_list_id: backlog.id, to_list_id: list1.id } described_class.new(project, user, params).execute @@ -33,7 +33,7 @@ describe Boards::Issues::MoveService, services: true do context 'when moving to backlog' do it 'removes all list-labels' do issue = create(:labeled_issue, project: project, labels: [bug, development, testing]) - params = { id: issue.iid, from: list1.id, to: backlog.id } + params = { id: issue.iid, from_list_id: list1.id, to_list_id: backlog.id } described_class.new(project, user, params).execute @@ -44,7 +44,7 @@ describe Boards::Issues::MoveService, services: true do context 'when moving from backlog to done' do it 'closes the issue' do issue = create(:labeled_issue, project: project, labels: [bug]) - params = { id: issue.iid, from: backlog.id, to: done.id } + params = { id: issue.iid, from_list_id: backlog.id, to_list_id: done.id } described_class.new(project, user, params).execute issue.reload @@ -56,7 +56,7 @@ describe Boards::Issues::MoveService, services: true do context 'when moving an issue between lists' do let(:issue) { create(:labeled_issue, project: project, labels: [bug, development]) } - let(:params) { { id: issue.iid, from: list1.id, to: list2.id } } + let(:params) { { id: issue.iid, from_list_id: list1.id, to_list_id: list2.id } } it 'delegates the label changes to Issues::UpdateService' do expect_any_instance_of(Issues::UpdateService).to receive(:execute).with(issue).once @@ -73,7 +73,7 @@ describe Boards::Issues::MoveService, services: true do context 'when moving to done' do let(:issue) { create(:labeled_issue, project: project, labels: [bug, development, testing]) } - let(:params) { { id: issue.iid, from: list2.id, to: done.id } } + let(:params) { { id: issue.iid, from_list_id: list2.id, to_list_id: done.id } } it 'delegates the close proceedings to Issues::CloseService' do expect_any_instance_of(Issues::CloseService).to receive(:execute).with(issue).once @@ -92,7 +92,7 @@ describe Boards::Issues::MoveService, services: true do context 'when moving from done' do let(:issue) { create(:labeled_issue, :closed, project: project, labels: [bug]) } - let(:params) { { id: issue.iid, from: done.id, to: list2.id } } + let(:params) { { id: issue.iid, from_list_id: done.id, to_list_id: list2.id } } it 'delegates the re-open proceedings to Issues::ReopenService' do expect_any_instance_of(Issues::ReopenService).to receive(:execute).with(issue).once @@ -112,7 +112,7 @@ describe Boards::Issues::MoveService, services: true do context 'when moving from done to backlog' do it 'reopens the issue' do issue = create(:labeled_issue, :closed, project: project, labels: [bug]) - params = { id: issue.iid, from: done.id, to: backlog.id } + params = { id: issue.iid, from_list_id: done.id, to_list_id: backlog.id } described_class.new(project, user, params).execute issue.reload