diff options
author | Mario de la Ossa <mdelaossa@gitlab.com> | 2018-06-07 20:54:24 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-06-07 20:54:24 +0000 |
commit | cf41aaba5ab9fb1d229807f77b2b77585d3550b0 (patch) | |
tree | 37405b49c29180d4fbf53efb3117163505ca0309 /app/models | |
parent | d4357afde55436a0fa3702d8d11bb8ae8a214381 (diff) | |
download | gitlab-ce-cf41aaba5ab9fb1d229807f77b2b77585d3550b0.tar.gz |
Backport of "Add assignee lists to boards"
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/list.rb | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/app/models/list.rb b/app/models/list.rb index 5daf35ef845..4edcfa78835 100644 --- a/app/models/list.rb +++ b/app/models/list.rb @@ -2,17 +2,27 @@ class List < ActiveRecord::Base belongs_to :board belongs_to :label - enum list_type: { backlog: 0, label: 1, closed: 2 } + enum list_type: { backlog: 0, label: 1, closed: 2, assignee: 3 } validates :board, :list_type, presence: true validates :label, :position, presence: true, if: :label? validates :label_id, uniqueness: { scope: :board_id }, if: :label? - validates :position, numericality: { only_integer: true, greater_than_or_equal_to: 0 }, if: :label? + validates :position, numericality: { only_integer: true, greater_than_or_equal_to: 0 }, if: :movable? before_destroy :can_be_destroyed - scope :destroyable, -> { where(list_type: list_types[:label]) } - scope :movable, -> { where(list_type: list_types[:label]) } + scope :destroyable, -> { where(list_type: list_types.slice(*destroyable_types).values) } + scope :movable, -> { where(list_type: list_types.slice(*movable_types).values) } + + class << self + def destroyable_types + [:label] + end + + def movable_types + [:label] + end + end def destroyable? label? |