From 2a10345c039e3ace0902f69d71dd214f6e5ccbb8 Mon Sep 17 00:00:00 2001 From: Leonid Beder Date: Tue, 18 Feb 2014 17:39:31 +0200 Subject: [PATCH] Simplified DB check. --- lib/health_monitor/providers/database.rb | 3 +-- spec/support/providers.rb | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/health_monitor/providers/database.rb b/lib/health_monitor/providers/database.rb index ddeaf5f..62f1850 100644 --- a/lib/health_monitor/providers/database.rb +++ b/lib/health_monitor/providers/database.rb @@ -5,8 +5,7 @@ class DatabaseException < StandardError; end class Database def check! # Check connection to the DB: - query = 'SELECT version FROM schema_migrations' - ActiveRecord::Base.connection.select_value(query).to_i + ActiveRecord::Migrator.current_version rescue Exception => e raise DatabaseException.new(e.message) end diff --git a/spec/support/providers.rb b/spec/support/providers.rb index 38d6c4c..8b6a07e 100644 --- a/spec/support/providers.rb +++ b/spec/support/providers.rb @@ -6,7 +6,7 @@ def stub_cache_failure end def stub_database_failure - ActiveRecord::Base.connection.stub(:select_value).and_raise(Exception) + ActiveRecord::Migrator.stub(:current_version).and_raise(Exception) end def stub_redis_failure