Extract new list position validation to a method

parent 22b8c0b7
...@@ -8,10 +8,7 @@ module Boards ...@@ -8,10 +8,7 @@ module Boards
def execute def execute
return false unless list.label? return false unless list.label?
return false if new_position.blank? return false if invalid_position?
return false if new_position == old_position
return false if new_position == first_position
return false if new_position == last_position
list.with_lock do list.with_lock do
reorder_intermediate_lists reorder_intermediate_lists
...@@ -27,6 +24,12 @@ module Boards ...@@ -27,6 +24,12 @@ module Boards
@list ||= board.lists.find(params[:list_id]) @list ||= board.lists.find(params[:list_id])
end end
def invalid_position?
return true if new_position.blank?
[old_position, first_position, last_position].include?(new_position)
end
def first_position def first_position
board.lists.first.try(:position) board.lists.first.try(:position)
end end
......
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