diff --git a/app/models/event.rb b/app/models/event.rb index 308ffd63961..b11b21bda3b 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -35,13 +35,21 @@ class Event < ActiveRecord::Base end # Next events currently enabled for system - # - push + # - push # - new issue # - merge request def allowed? push? || issue? || merge_request? || membership_changed? end + def project_name + if project + project.name + else + "(deleted)" + end + end + def push? action == self.class::Pushed && valid_push? end @@ -58,31 +66,31 @@ class Event < ActiveRecord::Base action == self.class::Reopened end - def issue? + def issue? target_type == "Issue" end - def merge_request? + def merge_request? target_type == "MergeRequest" end - def new_issue? - target_type == "Issue" && + def new_issue? + target_type == "Issue" && action == Created end - def new_merge_request? - target_type == "MergeRequest" && + def new_merge_request? + target_type == "MergeRequest" && action == Created end - def changed_merge_request? - target_type == "MergeRequest" && + def changed_merge_request? + target_type == "MergeRequest" && [Closed, Reopened].include?(action) end - def changed_issue? - target_type == "Issue" && + def changed_issue? + target_type == "Issue" && [Closed, Reopened].include?(action) end @@ -98,7 +106,7 @@ class Event < ActiveRecord::Base joined? || left? end - def issue + def issue target if target_type == "Issue" end @@ -106,7 +114,7 @@ class Event < ActiveRecord::Base target if target_type == "MergeRequest" end - def author + def author @author ||= User.find(author_id) end @@ -119,7 +127,7 @@ class Event < ActiveRecord::Base 'joined' elsif left? 'left' - else + else "opened" end end diff --git a/app/views/events/_event_membership_changed.html.haml b/app/views/events/_event_membership_changed.html.haml index b079c138f5a..464f24b3f03 100644 --- a/app/views/events/_event_membership_changed.html.haml +++ b/app/views/events/_event_membership_changed.html.haml @@ -2,7 +2,7 @@ %strong #{event.author_name} %span.event_label{class: event.action_name}= event.action_name project -%strong= link_to event.project.name, event.project +%strong= link_to event.project_name, event.project %span.cgray = time_ago_in_words(event.created_at) ago.