User joined project event added

This commit is contained in:
Alex Denisov 2012-09-09 23:18:28 +03:00
parent a56cec1132
commit a86bd87afc
10 changed files with 78 additions and 3 deletions

View file

@ -10,6 +10,7 @@ class Event < ActiveRecord::Base
Pushed = 5
Commented = 6
Merged = 7
Joined = 8 # User joined project
belongs_to :project
belongs_to :target, polymorphic: true
@ -37,7 +38,7 @@ class Event < ActiveRecord::Base
# - new issue
# - merge request
def allowed?
push? || issue? || merge_request?
push? || issue? || merge_request? || joined?
end
def push?
@ -84,6 +85,10 @@ class Event < ActiveRecord::Base
[Closed, Reopened].include?(action)
end
def joined?
action == self.class::Joined
end
def issue
target if target_type == "Issue"
end
@ -101,6 +106,8 @@ class Event < ActiveRecord::Base
"closed"
elsif merged?
"merged"
elsif joined?
'joined'
else
"opened"
end