-
Notifications
You must be signed in to change notification settings - Fork 1
/
app_test.rb
54 lines (47 loc) · 1.41 KB
/
app_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
43
44
45
46
47
48
49
50
51
52
53
54
require './app'
require 'test/unit'
require 'rack/test'
ENV['RACK_ENV'] = 'test'
class AppTest < Test::Unit::TestCase
include Rack::Test::Methods
def app
Sinatra::Application
end
def test_view_index
get '/'
assert last_response.ok?
end
def test_post_deployment_payload
old = Deployment.all
deployment = {
:created_at => "2012-10-17T20:36:02+00:00",
:application_name => "Application name",
:account_name => "Account name",
:changelog => "Changelog for deployment",
:description => "Information about deployment",
:revision => "Revision number",
:deployed_by => "Name of person deploying",
:version => "1.0"
}
post '/webhook', :deployment => deployment.to_json
assert_equal old.size + 1, Deployment.all.size
assert last_response.ok?
end
def test_post_alert_payload
old = Alert.all
alert = {
:created_at => "2012-10-19T16:55:05+00:00",
:application_name => "Application name",
:account_name => "Account name",
:severity => "Severity",
:message => "Message about alert",
:short_description => "Short description about alert",
:long_description => "Long description about alert",
:alert_url => "http://PATH_TO_NEW_RELIC",
:version => "1.0"
}
post '/webhook', :alert => alert.to_json
assert_equal old.size + 1, Alert.all.size
assert last_response.ok?
end
end