BigW Consortium Gitlab

Rename from/to params to from_list_id/to_list_id

parent 01b9744d
...@@ -43,7 +43,7 @@ class Projects::BoardIssuesController < Projects::ApplicationController ...@@ -43,7 +43,7 @@ class Projects::BoardIssuesController < Projects::ApplicationController
end end
def move_params def move_params
params.require(:issue).permit(:from, :to).merge(id: params[:id]) params.permit(:id, :from_list_id, :to_list_id)
end end
def record_not_found(exception) def record_not_found(exception)
......
...@@ -23,11 +23,11 @@ module Boards ...@@ -23,11 +23,11 @@ module Boards
end end
def moving_from def moving_from
@moving_from ||= board.lists.find_by(id: params[:from]) @moving_from ||= board.lists.find_by(id: params[:from_list_id])
end end
def moving_to def moving_to
@moving_to ||= board.lists.find_by(id: params[:to]) @moving_to ||= board.lists.find_by(id: params[:to_list_id])
end end
def close_service def close_service
......
...@@ -64,13 +64,13 @@ describe Projects::BoardIssuesController do ...@@ -64,13 +64,13 @@ describe Projects::BoardIssuesController do
context 'with valid params' do context 'with valid params' do
it 'returns a successful 200 response' 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) expect(response).to have_http_status(200)
end end
it 'moves issue to the desired list' do 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) expect(issue.reload.labels).to contain_exactly(development)
end end
...@@ -78,13 +78,13 @@ describe Projects::BoardIssuesController do ...@@ -78,13 +78,13 @@ describe Projects::BoardIssuesController do
context 'with invalid params' do context 'with invalid params' do
it 'returns a unprocessable entity 422 response for invalid lists' 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) expect(response).to have_http_status(422)
end end
it 'returns a not found 404 response for invalid issue id' do 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) expect(response).to have_http_status(404)
end end
...@@ -98,19 +98,20 @@ describe Projects::BoardIssuesController do ...@@ -98,19 +98,20 @@ describe Projects::BoardIssuesController do
end end
it 'returns a successful 403 response' do 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) expect(response).to have_http_status(403)
end end
end end
def move(user:, issue:, from:, to:) def move(user:, issue:, from_list_id:, to_list_id:)
sign_in(user) sign_in(user)
patch :update, namespace_id: project.namespace.to_param, patch :update, namespace_id: project.namespace.to_param,
project_id: project.to_param, project_id: project.to_param,
id: issue.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 format: :json
end end
end end
......
...@@ -22,7 +22,7 @@ describe Boards::Issues::MoveService, services: true do ...@@ -22,7 +22,7 @@ describe Boards::Issues::MoveService, services: true do
context 'when moving from backlog' do context 'when moving from backlog' do
it 'adds the label of the list it goes to' do it 'adds the label of the list it goes to' do
issue = create(:labeled_issue, project: project, labels: [bug]) 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 described_class.new(project, user, params).execute
...@@ -33,7 +33,7 @@ describe Boards::Issues::MoveService, services: true do ...@@ -33,7 +33,7 @@ describe Boards::Issues::MoveService, services: true do
context 'when moving to backlog' do context 'when moving to backlog' do
it 'removes all list-labels' do it 'removes all list-labels' do
issue = create(:labeled_issue, project: project, labels: [bug, development, testing]) 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 described_class.new(project, user, params).execute
...@@ -44,7 +44,7 @@ describe Boards::Issues::MoveService, services: true do ...@@ -44,7 +44,7 @@ describe Boards::Issues::MoveService, services: true do
context 'when moving from backlog to done' do context 'when moving from backlog to done' do
it 'closes the issue' do it 'closes the issue' do
issue = create(:labeled_issue, project: project, labels: [bug]) 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 described_class.new(project, user, params).execute
issue.reload issue.reload
...@@ -56,7 +56,7 @@ describe Boards::Issues::MoveService, services: true do ...@@ -56,7 +56,7 @@ describe Boards::Issues::MoveService, services: true do
context 'when moving an issue between lists' do context 'when moving an issue between lists' do
let(:issue) { create(:labeled_issue, project: project, labels: [bug, development]) } 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 it 'delegates the label changes to Issues::UpdateService' do
expect_any_instance_of(Issues::UpdateService).to receive(:execute).with(issue).once expect_any_instance_of(Issues::UpdateService).to receive(:execute).with(issue).once
...@@ -73,7 +73,7 @@ describe Boards::Issues::MoveService, services: true do ...@@ -73,7 +73,7 @@ describe Boards::Issues::MoveService, services: true do
context 'when moving to done' do context 'when moving to done' do
let(:issue) { create(:labeled_issue, project: project, labels: [bug, development, testing]) } 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 it 'delegates the close proceedings to Issues::CloseService' do
expect_any_instance_of(Issues::CloseService).to receive(:execute).with(issue).once expect_any_instance_of(Issues::CloseService).to receive(:execute).with(issue).once
...@@ -92,7 +92,7 @@ describe Boards::Issues::MoveService, services: true do ...@@ -92,7 +92,7 @@ describe Boards::Issues::MoveService, services: true do
context 'when moving from done' do context 'when moving from done' do
let(:issue) { create(:labeled_issue, :closed, project: project, labels: [bug]) } 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 it 'delegates the re-open proceedings to Issues::ReopenService' do
expect_any_instance_of(Issues::ReopenService).to receive(:execute).with(issue).once expect_any_instance_of(Issues::ReopenService).to receive(:execute).with(issue).once
...@@ -112,7 +112,7 @@ describe Boards::Issues::MoveService, services: true do ...@@ -112,7 +112,7 @@ describe Boards::Issues::MoveService, services: true do
context 'when moving from done to backlog' do context 'when moving from done to backlog' do
it 'reopens the issue' do it 'reopens the issue' do
issue = create(:labeled_issue, :closed, project: project, labels: [bug]) 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 described_class.new(project, user, params).execute
issue.reload issue.reload
......
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