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

Fix changing issue position inside list

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