summaryrefslogtreecommitdiff
path: root/app/models/project_services/chat_notification_service.rb
diff options
context:
space:
mode:
authorZ.J. van de Weg <git@zjvandeweg.nl>2017-03-23 08:16:48 +0100
committerZ.J. van de Weg <git@zjvandeweg.nl>2017-03-23 13:35:20 +0100
commit091c2608129445c6fe2dbe9a59e5fd3c78103d94 (patch)
tree047e20308c620e1c2d0a1955f490d3394aeec502 /app/models/project_services/chat_notification_service.rb
parentfed319b4ab763790865835eca35d179294883dd2 (diff)
downloadgitlab-ce-091c2608129445c6fe2dbe9a59e5fd3c78103d94.tar.gz
Improve readability and add test
Diffstat (limited to 'app/models/project_services/chat_notification_service.rb')
-rw-r--r--app/models/project_services/chat_notification_service.rb17
1 files changed, 7 insertions, 10 deletions
diff --git a/app/models/project_services/chat_notification_service.rb b/app/models/project_services/chat_notification_service.rb
index 1a26d97283e..75834103db5 100644
--- a/app/models/project_services/chat_notification_service.rb
+++ b/app/models/project_services/chat_notification_service.rb
@@ -17,7 +17,7 @@ class ChatNotificationService < Service
if properties.nil?
self.properties = {}
self.notify_only_broken_pipelines = true
- self.notify_only_default_branch = false
+ self.notify_only_default_branch = true
end
end
@@ -137,20 +137,17 @@ class ChatNotificationService < Service
end
def should_pipeline_be_notified?(data)
- notify_for_branch(data) && notify_for_pipeline(data)
+ notify_for_ref?(data) && notify_for_pipeline?(data)
end
- def notify_for_branch(data)
- ref_type = data[:object_attributes][:tag] ? 'tag' : 'branch'
+ def notify_for_ref?(data)
+ return true if data[:object_attributes][:tag]
+ return true unless notify_only_default_branch
- if ref_type == 'branch' && notify_only_default_branch
- data[:object_attributes][:ref] == project.default_branch
- else
- true
- end
+ data[:object_attributes][:ref] == project.default_branch
end
- def notify_for_pipeline(data)
+ def notify_for_pipeline?(data)
case data[:object_attributes][:status]
when 'success'
!notify_only_broken_pipelines?