summaryrefslogtreecommitdiff
path: root/app/workers
diff options
context:
space:
mode:
authorHoward P. Logsdon <howard@hplogsdon.com>2015-04-30 20:17:53 -0600
committerHoward P. Logsdon <howard@hplogsdon.com>2015-04-30 22:02:28 -0600
commitf2e65ba17b6b707111d9848d54f97f4fc4febe21 (patch)
tree381e049168afd0e6d127314ccc3a1bf9d8847ceb /app/workers
parent4c63ef932bc2b573cd9306066993f72c1cb8dc83 (diff)
downloadgitlab-ci-f2e65ba17b6b707111d9848d54f97f4fc4febe21.tar.gz
Fix notification issues on HipChatService, add HipChatMessage specs
adding specs for HipChatMessage exposed some issues with the way I was building the matrix-commit style notification message, so it ended up being quite a bit more changes than I expected. The save call from the service configure form submits an empty string as the server URL if left blank, which I've indicated to do in order to use the default server, but Hash#merge will happily overwrite a full string with a blank string if asked, so we need to break that out, along with the worker options which get mutated into string hash keys, of which the HipChat client seems to not understand. Additionally, add another spec to make sure we call the Sidekiq worker with expected arguments.
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/hip_chat_notifier_worker.rb15
1 files changed, 12 insertions, 3 deletions
diff --git a/app/workers/hip_chat_notifier_worker.rb b/app/workers/hip_chat_notifier_worker.rb
index 5bc7dda..0403578 100644
--- a/app/workers/hip_chat_notifier_worker.rb
+++ b/app/workers/hip_chat_notifier_worker.rb
@@ -2,8 +2,17 @@
class HipChatNotifierWorker
include Sidekiq::Worker
- def perform(room, token, message, options={})
- client = HipChat::Client.new(token, api_version: 'v2') # v1.5.0 requires explicit version (
- client[room].send("GitLab CI", message, options)
+ def perform(message, options={})
+ room = options.delete('room')
+ token = options.delete('token')
+ server = options.delete('server')
+ name = options.delete('service_name')
+ client_opts = {
+ api_version: 'v2',
+ server_url: server
+ }
+
+ client = HipChat::Client.new(token, client_opts)
+ client[room].send(name, message, options.symbolize_keys)
end
end