diff options
author | Z.J. van de Weg <git@zjvandeweg.nl> | 2017-03-23 08:16:48 +0100 |
---|---|---|
committer | Z.J. van de Weg <git@zjvandeweg.nl> | 2017-03-23 13:35:20 +0100 |
commit | 091c2608129445c6fe2dbe9a59e5fd3c78103d94 (patch) | |
tree | 047e20308c620e1c2d0a1955f490d3394aeec502 /app/models | |
parent | fed319b4ab763790865835eca35d179294883dd2 (diff) | |
download | gitlab-ce-091c2608129445c6fe2dbe9a59e5fd3c78103d94.tar.gz |
Improve readability and add test
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/project_services/chat_notification_service.rb | 17 |
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? |