diff options
author | Stan Hu <stanhu@gmail.com> | 2015-08-31 07:51:34 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2015-09-15 15:51:11 +0300 |
commit | d3d03d1362e576d194782a655cdfe9bc6ed5c596 (patch) | |
tree | 0b720ea7ac0b5df7e968df83ce25d8e571617a56 /app/models/event.rb | |
parent | 080a086d7644285af6cd4fb4b51c8f1c9b3aec95 (diff) |
Create a "destroyed Milestone" event and keep Milestone events around in the DB
for posterity.
Also fix issue where destroying a Milestone would cause odd, transient messages like
"created milestone" or "imported milestone".
Add "in" preposition when creating and destroying milestones
Closes #2382
Diffstat (limited to 'app/models/event.rb')
-rw-r--r-- | app/models/event.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/app/models/event.rb b/app/models/event.rb index 78f16c6304e..47600c57e35 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -27,6 +27,7 @@ class Event < ActiveRecord::Base MERGED = 7 JOINED = 8 # User joined project LEFT = 9 # User left project + DESTROYED = 10 delegate :name, :email, to: :author, prefix: true, allow_nil: true delegate :title, to: :issue, prefix: true, allow_nil: true @@ -48,6 +49,7 @@ class Event < ActiveRecord::Base scope :code_push, -> { where(action: PUSHED) } scope :in_projects, ->(project_ids) { where(project_id: project_ids).recent } scope :with_associations, -> { includes(project: :namespace) } + scope :for_milestone_id, ->(milestone_id) { where(target_type: "Milestone", target_id: milestone_id) } class << self def reset_event_cache_for(target) @@ -71,7 +73,7 @@ class Event < ActiveRecord::Base elsif created_project? true else - (issue? || merge_request? || note? || milestone?) && target + ((issue? || merge_request? || note?) && target) || milestone? end end @@ -115,6 +117,10 @@ class Event < ActiveRecord::Base action == LEFT end + def destroyed? + action == DESTROYED + end + def commented? action == COMMENTED end @@ -124,7 +130,7 @@ class Event < ActiveRecord::Base end def created_project? - created? && !target + created? && !target && target_type.nil? end def created_target? @@ -180,6 +186,8 @@ class Event < ActiveRecord::Base 'joined' elsif left? 'left' + elsif destroyed? + 'destroyed' elsif commented? "commented on" elsif created_project? |