Commit 4702f5f7 authored by Felipe Artur's avatar Felipe Artur

Fix changing issue position inside list

parent 7c545dee
...@@ -65,7 +65,7 @@ module Boards ...@@ -65,7 +65,7 @@ module Boards
end end
def move_params def move_params
params.permit(:board_id, :id, :from_list_id, :to_list_id, :move_before_iid, :move_after_iid) params.permit(:board_id, :id, :from_list_id, :to_list_id, :move_before_id, :move_after_id)
end end
def issue_params def issue_params
......
...@@ -44,7 +44,7 @@ module Boards ...@@ -44,7 +44,7 @@ module Boards
) )
end end
attrs[:move_between_iids] = move_between_iids if move_between_iids attrs[:move_between_ids] = move_between_ids if move_between_ids
attrs attrs
end end
...@@ -69,10 +69,10 @@ module Boards ...@@ -69,10 +69,10 @@ module Boards
Array(label_ids).compact Array(label_ids).compact
end end
def move_between_iids def move_between_ids
return unless params[:move_after_iid] || params[:move_before_iid] return unless params[:move_after_id] || params[:move_before_id]
[params[:move_after_iid], params[:move_before_iid]] [params[:move_after_id], params[:move_before_id]]
end end
end end
end end
......
...@@ -3,7 +3,7 @@ module Issues ...@@ -3,7 +3,7 @@ module Issues
include SpamCheckService include SpamCheckService
def execute(issue) def execute(issue)
handle_move_between_iids(issue) handle_move_between_ids(issue)
filter_spam_check_params filter_spam_check_params
change_issue_duplicate(issue) change_issue_duplicate(issue)
update(issue) update(issue)
...@@ -54,13 +54,13 @@ module Issues ...@@ -54,13 +54,13 @@ module Issues
end end
end end
def handle_move_between_iids(issue) def handle_move_between_ids(issue)
return unless params[:move_between_iids] return unless params[:move_between_ids]
after_iid, before_iid = params.delete(:move_between_iids) after_id, before_id = params.delete(:move_between_ids)
issue_before = get_issue_if_allowed(issue.project, before_iid) if before_iid issue_before = get_issue_if_allowed(before_id) if before_id
issue_after = get_issue_if_allowed(issue.project, after_iid) if after_iid issue_after = get_issue_if_allowed(after_id) if after_id
issue.move_between(issue_before, issue_after) issue.move_between(issue_before, issue_after)
end end
...@@ -76,8 +76,8 @@ module Issues ...@@ -76,8 +76,8 @@ module Issues
private private
def get_issue_if_allowed(project, iid) def get_issue_if_allowed(id)
issue = project.issues.find_by(iid: iid) issue = Issue.find(id)
issue if can?(current_user, :update_issue, issue) issue if can?(current_user, :update_issue, issue)
end end
......
...@@ -164,7 +164,7 @@ describe Boards::IssuesController do ...@@ -164,7 +164,7 @@ describe Boards::IssuesController do
post :create, board_id: board.to_param, post :create, board_id: board.to_param,
list_id: list.to_param, list_id: list.to_param,
issue: { title: title, project_id: project.id}, issue: { title: title, project_id: project.id },
format: :json format: :json
end end
end end
......
...@@ -163,7 +163,7 @@ describe Boards::IssuesController do ...@@ -163,7 +163,7 @@ describe Boards::IssuesController do
post :create, board_id: board.to_param, post :create, board_id: board.to_param,
list_id: list.to_param, list_id: list.to_param,
issue: { title: title, project_id: project_1.id}, issue: { title: title, project_id: project_1.id },
format: :json format: :json
end end
end end
......
...@@ -98,7 +98,7 @@ describe Boards::Issues::MoveService do ...@@ -98,7 +98,7 @@ describe Boards::Issues::MoveService do
issue.move_to_end && issue.save! issue.move_to_end && issue.save!
end end
params.merge!(move_after_iid: issue1.iid, move_before_iid: issue2.iid) params.merge!(move_after_id: issue1.id, move_before_id: issue2.id)
described_class.new(project, user, params).execute(issue) described_class.new(project, user, params).execute(issue)
......
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