summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2016-10-20 11:39:29 +0100
committerPhil Hughes <me@iamphill.com>2016-10-20 11:39:29 +0100
commit60a7cad96235d755f22249daf60b535fc4cc25dd (patch)
tree420e90d25bb38febf6aae65e7603f5a6f8288a6d /app/models
parent033988cf32da4d7a0ecdffac6e5b8e1b88a264f4 (diff)
parentba28a64ef93f44e45e6ec04a15f6170061f309e1 (diff)
downloadgitlab-ce-60a7cad96235d755f22249daf60b535fc4cc25dd.tar.gz
Merge branch 'master' into issue-board-sidebar
Diffstat (limited to 'app/models')
-rw-r--r--app/models/concerns/expirable.rb6
-rw-r--r--app/models/event.rb9
-rw-r--r--app/models/members/project_member.rb6
3 files changed, 18 insertions, 3 deletions
diff --git a/app/models/concerns/expirable.rb b/app/models/concerns/expirable.rb
index be93435453b..b66ba08dc59 100644
--- a/app/models/concerns/expirable.rb
+++ b/app/models/concerns/expirable.rb
@@ -5,11 +5,15 @@ module Expirable
scope :expired, -> { where('expires_at <= ?', Time.current) }
end
+ def expired?
+ expires? && expires_at <= Time.current
+ end
+
def expires?
expires_at.present?
end
def expires_soon?
- expires_at < 7.days.from_now
+ expires? && expires_at < 7.days.from_now
end
end
diff --git a/app/models/event.rb b/app/models/event.rb
index 0764cb8cabd..3993b35f96d 100644
--- a/app/models/event.rb
+++ b/app/models/event.rb
@@ -12,6 +12,7 @@ class Event < ActiveRecord::Base
JOINED = 8 # User joined project
LEFT = 9 # User left project
DESTROYED = 10
+ EXPIRED = 11 # User left project due to expiry
RESET_PROJECT_ACTIVITY_INTERVAL = 1.hour
@@ -115,6 +116,10 @@ class Event < ActiveRecord::Base
action == LEFT
end
+ def expired?
+ action == EXPIRED
+ end
+
def destroyed?
action == DESTROYED
end
@@ -124,7 +129,7 @@ class Event < ActiveRecord::Base
end
def membership_changed?
- joined? || left?
+ joined? || left? || expired?
end
def created_project?
@@ -184,6 +189,8 @@ class Event < ActiveRecord::Base
'joined'
elsif left?
'left'
+ elsif expired?
+ 'removed due to membership expiration from'
elsif destroyed?
'destroyed'
elsif commented?
diff --git a/app/models/members/project_member.rb b/app/models/members/project_member.rb
index 125f26369d7..e4880973117 100644
--- a/app/models/members/project_member.rb
+++ b/app/models/members/project_member.rb
@@ -121,7 +121,11 @@ class ProjectMember < Member
end
def post_destroy_hook
- event_service.leave_project(self.project, self.user)
+ if expired?
+ event_service.expired_leave_project(self.project, self.user)
+ else
+ event_service.leave_project(self.project, self.user)
+ end
super
end