Add tests for /uptime.
This commit is contained in:
parent
618241a458
commit
9d26844eaa
|
@ -7,8 +7,8 @@ class Travis::Api::App
|
||||||
begin
|
begin
|
||||||
ActiveRecord::Base.connection.execute('select 1')
|
ActiveRecord::Base.connection.execute('select 1')
|
||||||
[200, "OK"]
|
[200, "OK"]
|
||||||
rescue => e
|
rescue Exception => e
|
||||||
[500, "Error: #{e.message}"]
|
return [500, "Error: #{e.message}"]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
20
spec/integration/uptime_spec.rb
Normal file
20
spec/integration/uptime_spec.rb
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe 'Uptime' do
|
||||||
|
after do
|
||||||
|
ActiveRecord::Base.connection.unstub(:execute)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns a 200 and ok when the request was successful' do
|
||||||
|
response = get '/uptime'
|
||||||
|
response.status.should == 200
|
||||||
|
response.body.should == "OK"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns a 500 when the query wasn't successful" do
|
||||||
|
ActiveRecord::Base.connection.stubs(:execute).raises(StandardError, 'error!')
|
||||||
|
response = get '/uptime'
|
||||||
|
response.status.should == 500
|
||||||
|
response.body.should == "Error: error!"
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user