Commit 759fb518eb28ca59913f1c897b3cc056693709ca
1 parent
dc37c8aa
Exists in
master
and in
4 other branches
fix event issue when event for left project + project removed
Showing
2 changed files
with
23 additions
and
15 deletions
Show diff stats
app/models/event.rb
| @@ -35,13 +35,21 @@ class Event < ActiveRecord::Base | @@ -35,13 +35,21 @@ class Event < ActiveRecord::Base | ||
| 35 | end | 35 | end |
| 36 | 36 | ||
| 37 | # Next events currently enabled for system | 37 | # Next events currently enabled for system |
| 38 | - # - push | 38 | + # - push |
| 39 | # - new issue | 39 | # - new issue |
| 40 | # - merge request | 40 | # - merge request |
| 41 | def allowed? | 41 | def allowed? |
| 42 | push? || issue? || merge_request? || membership_changed? | 42 | push? || issue? || merge_request? || membership_changed? |
| 43 | end | 43 | end |
| 44 | 44 | ||
| 45 | + def project_name | ||
| 46 | + if project | ||
| 47 | + project.name | ||
| 48 | + else | ||
| 49 | + "(deleted)" | ||
| 50 | + end | ||
| 51 | + end | ||
| 52 | + | ||
| 45 | def push? | 53 | def push? |
| 46 | action == self.class::Pushed && valid_push? | 54 | action == self.class::Pushed && valid_push? |
| 47 | end | 55 | end |
| @@ -58,31 +66,31 @@ class Event < ActiveRecord::Base | @@ -58,31 +66,31 @@ class Event < ActiveRecord::Base | ||
| 58 | action == self.class::Reopened | 66 | action == self.class::Reopened |
| 59 | end | 67 | end |
| 60 | 68 | ||
| 61 | - def issue? | 69 | + def issue? |
| 62 | target_type == "Issue" | 70 | target_type == "Issue" |
| 63 | end | 71 | end |
| 64 | 72 | ||
| 65 | - def merge_request? | 73 | + def merge_request? |
| 66 | target_type == "MergeRequest" | 74 | target_type == "MergeRequest" |
| 67 | end | 75 | end |
| 68 | 76 | ||
| 69 | - def new_issue? | ||
| 70 | - target_type == "Issue" && | 77 | + def new_issue? |
| 78 | + target_type == "Issue" && | ||
| 71 | action == Created | 79 | action == Created |
| 72 | end | 80 | end |
| 73 | 81 | ||
| 74 | - def new_merge_request? | ||
| 75 | - target_type == "MergeRequest" && | 82 | + def new_merge_request? |
| 83 | + target_type == "MergeRequest" && | ||
| 76 | action == Created | 84 | action == Created |
| 77 | end | 85 | end |
| 78 | 86 | ||
| 79 | - def changed_merge_request? | ||
| 80 | - target_type == "MergeRequest" && | 87 | + def changed_merge_request? |
| 88 | + target_type == "MergeRequest" && | ||
| 81 | [Closed, Reopened].include?(action) | 89 | [Closed, Reopened].include?(action) |
| 82 | end | 90 | end |
| 83 | 91 | ||
| 84 | - def changed_issue? | ||
| 85 | - target_type == "Issue" && | 92 | + def changed_issue? |
| 93 | + target_type == "Issue" && | ||
| 86 | [Closed, Reopened].include?(action) | 94 | [Closed, Reopened].include?(action) |
| 87 | end | 95 | end |
| 88 | 96 | ||
| @@ -98,7 +106,7 @@ class Event < ActiveRecord::Base | @@ -98,7 +106,7 @@ class Event < ActiveRecord::Base | ||
| 98 | joined? || left? | 106 | joined? || left? |
| 99 | end | 107 | end |
| 100 | 108 | ||
| 101 | - def issue | 109 | + def issue |
| 102 | target if target_type == "Issue" | 110 | target if target_type == "Issue" |
| 103 | end | 111 | end |
| 104 | 112 | ||
| @@ -106,7 +114,7 @@ class Event < ActiveRecord::Base | @@ -106,7 +114,7 @@ class Event < ActiveRecord::Base | ||
| 106 | target if target_type == "MergeRequest" | 114 | target if target_type == "MergeRequest" |
| 107 | end | 115 | end |
| 108 | 116 | ||
| 109 | - def author | 117 | + def author |
| 110 | @author ||= User.find(author_id) | 118 | @author ||= User.find(author_id) |
| 111 | end | 119 | end |
| 112 | 120 | ||
| @@ -119,7 +127,7 @@ class Event < ActiveRecord::Base | @@ -119,7 +127,7 @@ class Event < ActiveRecord::Base | ||
| 119 | 'joined' | 127 | 'joined' |
| 120 | elsif left? | 128 | elsif left? |
| 121 | 'left' | 129 | 'left' |
| 122 | - else | 130 | + else |
| 123 | "opened" | 131 | "opened" |
| 124 | end | 132 | end |
| 125 | end | 133 | end |
app/views/events/_event_membership_changed.html.haml
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | %strong #{event.author_name} | 2 | %strong #{event.author_name} |
| 3 | %span.event_label{class: event.action_name}= event.action_name | 3 | %span.event_label{class: event.action_name}= event.action_name |
| 4 | project | 4 | project |
| 5 | -%strong= link_to event.project.name, event.project | 5 | +%strong= link_to event.project_name, event.project |
| 6 | %span.cgray | 6 | %span.cgray |
| 7 | = time_ago_in_words(event.created_at) | 7 | = time_ago_in_words(event.created_at) |
| 8 | ago. | 8 | ago. |