Extract new list position validation to a method

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