diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-08-16 11:31:21 -0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-08-17 12:58:59 -0300 |
commit | c6511235e4253d11447b40c2ea42ecb02c99687e (patch) | |
tree | ae7d2d39479ecde85682b55a68227df056ffa019 /app/models/list.rb | |
parent | 29a91c5bc65524fffeaaba493f30c419b98f0869 (diff) | |
download | gitlab-ce-c6511235e4253d11447b40c2ea42ecb02c99687e.tar.gz |
Add a destroyable scope and a destroyable? method to List model
Diffstat (limited to 'app/models/list.rb')
-rw-r--r-- | app/models/list.rb | 10 |
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 |