Add tests for /uptime.

This commit is contained in:
Mathias Meyer 2013-08-26 17:29:10 +02:00
parent 618241a458
commit 9d26844eaa
2 changed files with 22 additions and 2 deletions

View File

@ -7,8 +7,8 @@ class Travis::Api::App
begin
ActiveRecord::Base.connection.execute('select 1')
[200, "OK"]
rescue => e
[500, "Error: #{e.message}"]
rescue Exception => e
return [500, "Error: #{e.message}"]
end
end
end

View 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