Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-08-16 17:31:21 +0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-08-17 18:58:59 +0300
commitc6511235e4253d11447b40c2ea42ecb02c99687e (patch)
treeae7d2d39479ecde85682b55a68227df056ffa019 /app/models/list.rb
parent29a91c5bc65524fffeaaba493f30c419b98f0869 (diff)
Add a destroyable scope and a destroyable? method to List model
Diffstat (limited to 'app/models/list.rb')
-rw-r--r--app/models/list.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/app/models/list.rb b/app/models/list.rb
index 41f79513a10..634c012e543 100644
--- a/app/models/list.rb
+++ b/app/models/list.rb
@@ -9,7 +9,13 @@ class List < ActiveRecord::Base
validates :label_id, uniqueness: { scope: :board_id }, if: :label?
validates :position, numericality: { only_integer: true, greater_than_or_equal_to: 0 }, if: :label?
- before_destroy :can_be_destroyed, unless: :label?
+ before_destroy :can_be_destroyed
+
+ scope :destroyable, -> { where(list_type: list_types[:label]) }
+
+ def destroyable?
+ label?
+ end
def title
label? ? label.name : list_type.humanize
@@ -18,6 +24,6 @@ class List < ActiveRecord::Base
private
def can_be_destroyed
- false
+ destroyable?
end
end