diff options
author | Rémy Coutable <remy@rymai.me> | 2016-07-26 12:55:00 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-07-26 12:56:56 +0300 |
commit | 255162e194918d1d9c3cd7c0c6d3927e3f2006bc (patch) | |
tree | 368ea7a1df4a2d45acf39a5ec1db6d7a3ade299d /app/models | |
parent | 189e3b575a739c65665af172d607eded967d348f (diff) |
Little refactor, add specs, and a CHANGELOG entry
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/project_services/hipchat_service.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/app/models/project_services/hipchat_service.rb b/app/models/project_services/hipchat_service.rb index 413200199b4..4fc8d640310 100644 --- a/app/models/project_services/hipchat_service.rb +++ b/app/models/project_services/hipchat_service.rb @@ -67,7 +67,7 @@ class HipchatService < Service @gate ||= HipChat::Client.new(token, options) end - def message_options(data) + def message_options(data = nil) { notify: notify.present? && notify == '1', color: build_status_color(data) || color || 'yellow' } end @@ -241,11 +241,14 @@ class HipchatService < Service end def build_status_color(data) - if data[:commit][:status] == 'success' + return unless data && data[:object_kind] == 'build' + + case data[:commit][:status] + when 'success' 'green' else 'red' - end if data[:object_kind] == 'build' + end end def project_name |