Rework of milestones
This commit is contained in:
parent
b01f8b63c2
commit
190e483fb4
8 changed files with 72 additions and 34 deletions
|
@ -19,12 +19,19 @@ class Milestone < ActiveRecord::Base
|
|||
has_many :issues
|
||||
has_many :merge_requests
|
||||
|
||||
scope :active, where(closed: false)
|
||||
scope :closed, where(closed: true)
|
||||
|
||||
validates :title, presence: true
|
||||
validates :project, presence: true
|
||||
validates :closed, inclusion: { in: [true, false] }
|
||||
|
||||
def self.active
|
||||
where("due_date > ? OR due_date IS NULL", Date.today)
|
||||
def expired?
|
||||
if due_date
|
||||
due_date < Date.today
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
def participants
|
||||
|
@ -52,4 +59,12 @@ class Milestone < ActiveRecord::Base
|
|||
def expires_at
|
||||
"expires at #{due_date.stamp("Aug 21, 2011")}" if due_date
|
||||
end
|
||||
|
||||
def can_be_closed?
|
||||
issues.count > 0 && open? && issues.opened.count.zero?
|
||||
end
|
||||
|
||||
def open?
|
||||
!closed
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,7 +22,7 @@ class Snippet < ActiveRecord::Base
|
|||
belongs_to :author, class_name: "User"
|
||||
has_many :notes, as: :noteable, dependent: :destroy
|
||||
|
||||
delegate :name, :email, to: :author, prefix: true
|
||||
delegate :name, :email, to: :author, prefix: true, allow_nil: true
|
||||
|
||||
validates :author, presence: true
|
||||
validates :project, presence: true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue