Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 4 files changed
  • 0 comments
  • 1 contributor
10 lib/proby/notifier.rb
@@ -7,8 +7,8 @@ def self.send_notification(type, proby_task_id, options={})
7 7 return nil
8 8 end
9 9
10   - proby_task_id = ENV['PROBY_TASK_ID'] if is_blank?(proby_task_id)
11   - if is_blank?(proby_task_id)
  10 + proby_task_id = ENV['PROBY_TASK_ID'] if blank?(proby_task_id)
  11 + if blank?(proby_task_id)
12 12 Proby.logger.warn "Proby: No notification sent because task ID was not specified"
13 13 return nil
14 14 end
@@ -23,12 +23,6 @@ def self.send_notification(type, proby_task_id, options={})
23 23 Proby.logger.error e.backtrace
24 24 end
25 25
26   - private
27   -
28   - def self.is_blank?(string)
29   - string.nil? || string.strip == ''
30   - end
31   -
32 26 end
33 27 end
34 28
7 lib/proby/proby_http_api.rb
@@ -4,6 +4,8 @@ class ProbyHttpApi
4 4 base_uri "https://proby.signalhq.com"
5 5 default_timeout 5
6 6
  7 + protected
  8 +
7 9 def self.handle_api_failure(response)
8 10 if response.code == 401
9 11 raise AuthFailedException.new("Authentication to Proby failed. Make sure your API key is correct.")
@@ -17,5 +19,10 @@ def self.handle_api_failure(response)
17 19 def self.default_headers
18 20 { 'api_key' => Proby.api_key, 'Content-Type' => 'application/json' }
19 21 end
  22 +
  23 + def self.blank?(s)
  24 + s.nil? || s.strip.empty?
  25 + end
  26 +
20 27 end
21 28 end
4 lib/proby/proby_task.rb
@@ -274,9 +274,5 @@ def self.ensure_api_key_set
274 274 end
275 275 end
276 276
277   - def self.blank?(s)
278   - s.nil? || s.strip.empty?
279   - end
280   -
281 277 end
282 278 end
10 test/notifier_test.rb
@@ -30,29 +30,29 @@ def teardown
30 30 end
31 31
32 32 should "send a start notification if a task_id is specified in the call" do
33   - FakeWeb.register_uri(:post, "https://proby.signalhq.com/api/v1/tasks/abc123xyz456/start.json", :status => ["200", "OK"])
  33 + FakeWeb.register_uri(:post, Proby::ProbyHttpApi.base_uri + "/api/v1/tasks/abc123xyz456/start.json", :status => ["200", "OK"])
34 34 assert_equal 200, Proby.send_start_notification("abc123xyz456")
35 35 end
36 36
37 37 should "send a start notification if a task_id is specified in an environment variable" do
38 38 ENV['PROBY_TASK_ID'] = "uuu777sss999"
39   - FakeWeb.register_uri(:post, "https://proby.signalhq.com/api/v1/tasks/uuu777sss999/start.json", :status => ["200", "OK"])
  39 + FakeWeb.register_uri(:post, Proby::ProbyHttpApi.base_uri + "/api/v1/tasks/uuu777sss999/start.json", :status => ["200", "OK"])
40 40 assert_equal 200, Proby.send_start_notification
41 41 end
42 42
43 43 should "send a finish notification if a task_id is specified in the call" do
44   - FakeWeb.register_uri(:post, "https://proby.signalhq.com/api/v1/tasks/abc123xyz456/finish.json", :status => ["200", "OK"])
  44 + FakeWeb.register_uri(:post, Proby::ProbyHttpApi.base_uri + "/api/v1/tasks/abc123xyz456/finish.json", :status => ["200", "OK"])
45 45 assert_equal 200, Proby.send_finish_notification("abc123xyz456")
46 46 end
47 47
48 48 should "send a finish notification with options if options are specified" do
49   - FakeWeb.register_uri(:post, "https://proby.signalhq.com/api/v1/tasks/abc123xyz456/finish.json", :status => ["200", "OK"])
  49 + FakeWeb.register_uri(:post, Proby::ProbyHttpApi.base_uri + "/api/v1/tasks/abc123xyz456/finish.json", :status => ["200", "OK"])
50 50 assert_equal 200, Proby.send_finish_notification("abc123xyz456", :failed => true, :error_message => "something bad happened")
51 51 end
52 52
53 53 should "send a finish notification if a task_id is specified in an environment variable" do
54 54 ENV['PROBY_TASK_ID'] = "iii999ooo222"
55   - FakeWeb.register_uri(:post, "https://proby.signalhq.com/api/v1/tasks/iii999ooo222/finish.json", :status => ["200", "OK"])
  55 + FakeWeb.register_uri(:post, Proby::ProbyHttpApi.base_uri + "/api/v1/tasks/iii999ooo222/finish.json", :status => ["200", "OK"])
56 56 assert_equal 200, Proby.send_finish_notification
57 57 end
58 58 end

No commit comments for this range

Something went wrong with that request. Please try again.