forked from github/github-services
/
ontime_test.rb
42 lines (34 loc) · 1.13 KB
/
ontime_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__)
require 'cgi'
class OnTimeTest < Service::TestCase
def setup
@stubs = Faraday::Adapter::Test::Stubs.new
end
# This tests the old api paths of OnTime. Where 11.1.0 <= Version < 12.2.0
def test_push
@stubs.get "/api/version" do |env|
assert_equal 'www.example.com', env[:url].host
[200, {}, '{"data":{"major":12,"minor":0,"build":2}}']
end
@stubs.post "/api/github" do |env|
[200, {}, '']
end
svc = service({'ontime_url' => 'http://www.example.com/', 'api_key' => 'test_api_key'}, payload)
svc.receive_push
end
# This tests the new api path for GitHub in OnTime Version 12.2 and later.
def test_push_v1_api
@stubs.get "/v122/api/version" do |env|
assert_equal 'www.example.com', env[:url].host
[200, {}, '{"data":{"major":12,"minor":2,"build":0}}']
end
@stubs.post "/v122/api/v1/github" do |env|
[200, {}, '']
end
svc = service({'ontime_url' => 'http://www.example.com/v122', 'api_key' => 'test_v1_api_key'}, payload)
svc.receive_push
end
def service(*args)
super Service::OnTime, *args
end
end