forked from github/github-services
-
Notifications
You must be signed in to change notification settings - Fork 0
/
notifo_test.rb
43 lines (35 loc) · 1.07 KB
/
notifo_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
require File.expand_path('../helper', __FILE__)
class NotifoTest < Service::TestCase
def setup
@stubs = Faraday::Adapter::Test::Stubs.new
end
def test_push
subscribed = %w(a b)
notified = %w(a b)
@stubs.post "/v1/subscribe_user" do |env|
assert_equal 'api.notifo.com', env[:url].host
data = Rack::Utils.parse_nested_query(env[:body])
assert_equal subscribed.shift, data['username']
[200, {}, '']
end
@stubs.post "/v1/send_notification" do |env|
assert_equal 'api.notifo.com', env[:url].host
data = Rack::Utils.parse_nested_query(env[:body])
assert_equal notified.shift, data['to']
[200, {}, '']
end
svc = service({'subscribers' => 'a,b'}, payload)
svc.secrets = {'notifo' => {'apikey' => 'a'}}
svc.receive_push
end
def test_push_with_empty_commits
data = payload
data['commits'] = []
svc = service({'subscribers' => 'a,b'}, data)
svc.secrets = {'notifo' => {'apikey' => 'a'}}
svc.receive_push
end
def service(*args)
super Service::Notifo, *args
end
end