Skip to content

Commit

Permalink
Merge pull request #10 from joshdvir/master
Browse files Browse the repository at this point in the history
Adding a default time to environment vars
  • Loading branch information
lbeder committed Aug 18, 2016
2 parents fea48ee + 4dfc65f commit 8f8c0aa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
8 changes: 4 additions & 4 deletions app/controllers/health_monitor/health_controller.rb
Expand Up @@ -10,10 +10,10 @@ class HealthController < ActionController::Base
def check
res = HealthMonitor.check(request: request)

unless HealthMonitor.configuration.environmet_variables.nil?
env_vars = [environmet_variables: HealthMonitor.configuration.environmet_variables]
res[:results] = env_vars + res[:results]
end
HealthMonitor.configuration.environmet_variables ||= {}
v = HealthMonitor.configuration.environmet_variables.merge(time: Time.now.to_s(:db))
env_vars = [environmet_variables: v]
res[:results] = env_vars + res[:results]

self.content_type = Mime[:json]
self.status = res[:status]
Expand Down
2 changes: 1 addition & 1 deletion lib/health_monitor/version.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module HealthMonitor
VERSION = '5.0.0'.freeze
VERSION = '5.0.1'.freeze
end
12 changes: 11 additions & 1 deletion spec/controllers/health_monitor/health_controller_spec.rb
Expand Up @@ -39,6 +39,9 @@

expect(response).to be_ok
expect(JSON.parse(response.body)).to eq([{
'environmet_variables' => { 'time' => '1990-01-01 00:00:00' }
},
{
'database' => {
'message' => '',
'status' => 'OK',
Expand Down Expand Up @@ -87,7 +90,8 @@
{
'environmet_variables' => {
'build_number' => '12',
'git_sha' => 'example_sha'
'git_sha' => 'example_sha',
'time' => '1990-01-01 00:00:00'
}
},
{
Expand Down Expand Up @@ -118,6 +122,9 @@

expect(response).to be_ok
expect(JSON.parse(response.body)).to eq([{
'environmet_variables' => { 'time' => '1990-01-01 00:00:00' }
},
{
'database' => {
'message' => '',
'status' => 'OK',
Expand All @@ -138,6 +145,9 @@

expect(response).to be_error
expect(JSON.parse(response.body)).to eq([{
'environmet_variables' => { 'time' => '1990-01-01 00:00:00' }
},
{
'database' => {
'message' => 'Exception',
'status' => 'ERROR',
Expand Down

0 comments on commit 8f8c0aa

Please sign in to comment.