= Change Log =

*1.5.1
  * Created pre_rails4 branch (versions < 2.0) for rails 2.3 and 3.x; with master branch for rails 4.0+
*1.5.0
  * Fixed SMTP test now uses CRNL as per RFC
  * Check Action
* 1.4.1 - Rails 4 and route changes
  * Now handles routes being generated multiple times by some gem / rails / ruby combinations - Previously multiple calls to health_check_routes where ignored, now explicit calls to health_check_route always adds the route but flags that it doesn't have to be added again on the end of the list
  * Uses ActiveRecord::Migration.check_pending! if available and returns the message if an exception is raised (Rails 4.0+)
  * Simplified routing rules down to one rule for Rails 3.0+
  * Includes some changes for rails 4.1 (edge) - but still a work in progress
* 1.3.1 - Include changes from contributers:
  * Migrations with dots are now handled
  * the list of checks for "full" / "all" can be configured
* 1.2.0 - The gem can now be configured, including timeouts, status codes and text returned on success
        - Customn checks can be added via initializer like config.add_custom_check { CustomCheckClass.a_custom_check }
	- You can now request the response to be json or xml (via url or Content-accepted header)
	- reduced tests to the versions of ruby recomended for the different versions of rails
* 1.1.2 - Change to bundler support for building gems, as jeweler gem was broken by v2.0.0 of rubygems
* 1.1.0 - Include cache check (Thanks to https://github.com/mgomes1 ) and some changes to test setup to workaround and diagnose test failures under rvm
* 1.0.2 - Included travis config and gemfiles used in travis tests in gem and changes to test setup so that gem test 
* 1.x - Includes Rails 3.x suppprt as an Engine
* 0.x - Rails 2.3

+
 end
 
diff --git a/README.rdoc b/README.rdoc
index de48110..cf673e8 100644
--- a/README.rdoc
+++ b/README.rdoc
@@ -24,11 +24,11 @@ On failure a 500 http status is returned with a simple explanation of the failur
     curl localhost:3000/health_check/fail
     health_check failed: invalid argument to health_test.
 
-The health_check controller disables sessions and logging for its actions to minimise the impact of frequent uptime checks on the session store and the log file.
+The health_check controller disables sessions for versions that eagerly load sessions. Only failures are logged for rails < '4.1'.
 
 == Checks
 
-* standard (default) - site, database and migrations checks are run plus email if settings have been changed
+* standard (default) - site, database and migrations checks are run plus email if ActionMailer is defined and it is not using the default configuration
 * all / full - all checks are run (can be overriden in config block)
 * database - checks that the current migration level can be read from the database
 * email - basic check of email - :test returns true, :sendmail checks file is present and executable, :smtp sends HELO command to server and checks response
@@ -100,6 +100,9 @@ To change the configuration of health_check, create a file `config/initializers/
 
       config.http_status_for_error_object = 500
 
+      # You can customize which checks happen on a standard health check
+      config.standard_checks = [ 'database', 'migrations', 'custom' ]
+
       # You can set what tests are run with the 'full' or 'all' parameter
       config.full_checks = ['database', 'migrations', 'custom', 'email', 'cache']
 
@@ -189,11 +192,10 @@ See https://github.com/ianheggie/health_check/wiki/Ajax-Example for an Ajax exam
 
 === Automated testing and other checks
 
-Travis CI runs the tests: {<img src="https://travis-ci.org/ianheggie/health_check.png">}[https://travis-ci.org/ianheggie/health_check]
-
-Code Climate monitors code quality: {<img src="https://codeclimate.com/github/ianheggie/health_check.png" />}[https://codeclimate.com/github/ianheggie/health_check]
-
-Gemnasium monitors gem dependencies {<img src="https://gemnasium.com/ianheggie/health_check.png">}[https://gemnasium.com/ianheggie/health_check]
+* {<img src="https://badge.fury.io/rb/health_check.png" alt="Gem Version" />}[http://badge.fury.io/rb/health_check] - Latest Gem
+* {<img src="https://travis-ci.org/ianheggie/health_check.png">}[https://travis-ci.org/ianheggie/health_check]  - Travis CI 
+* {<img src="https://codeclimate.com/github/ianheggie/health_check.png" />}[https://codeclimate.com/github/ianheggie/health_check] - Code quality
+* {<img src="https://gemnasium.com/ianheggie/health_check.png">}[https://gemnasium.com/ianheggie/health_check] - Gem dependencies 
 
 === Manual testing
 
@@ -230,10 +232,18 @@ The command `rake test` will also launch these tests, except it cannot install t
 
 == Copyright
 
-Copyright (c) 2010-2013 Ian Heggie, released under the MIT license.
+Copyright (c) 2010-2014 Ian Heggie, released under the MIT license.
 See MIT-LICENSE for details.
 
 == Contributors
 
-Thanks go to the various people who have given feedback and suggestions via the issues list and pull requests
+Thanks go to the various people who have given feedback and suggestions via the issues list and pull requests.
+
+=== Contributing
+
+1. Fork it
+2. Create your feature branch (`git checkout -b my-new-feature`)
+3. Commit your changes (`git commit -am 'Add some feature'`)
+4. Push to the branch (`git push origin my-new-feature`)
+5. Create new Pull Request (Code with BDD tests are favoured)
 
diff --git a/health_check.gemspec b/health_check.gemspec
index 1b7f8fc..e6b70f5 100644
--- a/health_check.gemspec
+++ b/health_check.gemspec
@@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
   gem.description = <<-EOF
   	Simple health check of Rails app for uptime monitoring with Pingdom, NewRelic, EngineYard or uptime.openacs.org etc.
   EOF
-  gem.homepage      = "http://ianheggie.github.io/health_check/"
+  gem.homepage      = "https://github.com/ianheggie/health_check"
 
   gem.files         = `git ls-files`.split($/)
   gem.executables   = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -23,6 +23,5 @@ Gem::Specification.new do |gem|
   gem.add_dependency(%q<rails>, [">= 2.3.0"])
   gem.add_development_dependency(%q<rake>, [">= 0.8.3"])
   gem.add_development_dependency(%q<shoulda>, ["~> 2.11.0"])
-  gem.add_development_dependency(%q<sqlite3>, ["~> 1.3.7"])
   gem.add_development_dependency(%q<bundler>, ["~> 1.2"])
 end
diff --git a/lib/health_check.rb b/lib/health_check.rb
index 04d6aec..45f8fd2 100644
--- a/lib/health_check.rb
+++ b/lib/health_check.rb
@@ -28,8 +28,10 @@ module HealthCheck
   # Array of custom check blocks
   mattr_accessor :custom_checks
   mattr_accessor :full_checks
+  mattr_accessor :standard_checks
   self.custom_checks = [ ]
   self.full_checks = ['database', 'migrations', 'custom', 'email', 'cache']
+  self.standard_checks = [ 'database', 'migrations', 'custom' ]
 
   def self.add_custom_check(&block)
     custom_checks << block
diff --git a/lib/health_check/health_check_controller.rb b/lib/health_check/health_check_controller.rb
index 4b5fa7a..7d544f7 100644
--- a/lib/health_check/health_check_controller.rb
+++ b/lib/health_check/health_check_controller.rb
@@ -4,8 +4,6 @@
 module HealthCheck
   class HealthCheckController < ActionController::Base
 
-    session(:off) if Rails.version < '3.0'
-
     layout false if self.respond_to? :layout
 
     def index
@@ -34,9 +32,9 @@ module HealthCheck
         end
         # Log a single line as some uptime checkers only record that it failed, not the text returned
         if logger
-          silence_level, logger.level = logger.level, @old_logger_level
+          silence_level, logger.level = logger.level, @old_logger_level if @old_logger_level
           logger.info msg
-          logger.level = silence_level
+          logger.level = silence_level if @old_logger_level
         end
       end
     end
diff --git a/lib/health_check/utils.rb b/lib/health_check/utils.rb
index b6da3f8..e7a10f6 100644
--- a/lib/health_check/utils.rb
+++ b/lib/health_check/utils.rb
@@ -46,8 +46,8 @@ module HealthCheck
           when 'cache'
             errors << HealthCheck::Utils.check_cache
           when "standard"
-            errors << HealthCheck::Utils.process_checks("database_migrations_custom")
-            errors << HealthCheck::Utils.process_checks("email") unless HealthCheck::Utils.default_action_mailer_configuration?
+            errors << HealthCheck::Utils.process_checks(HealthCheck.standard_checks.join('_'))
+            errors << HealthCheck::Utils.process_checks("email") if HealthCheck::Utils.mailer_configured?
           when "custom"
             HealthCheck.custom_checks.each do |custom_check|
               errors << custom_check.call(self)
@@ -71,8 +71,8 @@ module HealthCheck
       @@db_migrate_path = value
     end
 
-    def self.default_action_mailer_configuration?
-      ActionMailer::Base.delivery_method == :smtp && HealthCheck::Utils.default_smtp_settings == ActionMailer::Base.smtp_settings
+    def self.mailer_configured?
+      defined?(ActionMailer::Base) && (ActionMailer::Base.delivery_method != :smtp || HealthCheck::Utils.default_smtp_settings != ActionMailer::Base.smtp_settings)
     end
 
     def self.get_database_version
@@ -117,11 +117,11 @@ module HealthCheck
               while status != nil && status !~ /^2/
                 status = t.gets
               end
-              t.puts "HELO #{settings[:domain]}"
+              t.puts "HELO #{settings[:domain]}\r"
               while status != nil && status !~ /^250/
                 status = t.gets
               end
-              t.puts "QUIT"
+              t.puts "QUIT\r"
               status = t.gets
             ensure
               t.close
diff --git a/lib/health_check/version.rb b/lib/health_check/version.rb
index 8264365..0cf2f60 100644
--- a/lib/health_check/version.rb
+++ b/lib/health_check/version.rb
@@ -1,4 +1,4 @@
 module HealthCheck
-  VERSION = "1.4.1"
+  VERSION = "1.5.0"
 end
 
diff --git a/test/fake_smtp_server b/test/fake_smtp_server
index e55ee3a..7f1e645 100755
--- a/test/fake_smtp_server
+++ b/test/fake_smtp_server
@@ -23,8 +23,8 @@ client = server.accept    # Wait for a client to connect
 send(client, "220 dummy-smtp.example.com SMTP")
 cmd = receive(client)
 
-while cmd !~ /^QUIT/
-  if cmd =~ /^HELO/
+while cmd !~ /^QUIT\r/
+  if cmd =~ /^HELO(.*)\r/
     send(client, "250 Welcome to a dummy smtp server")
   else
     send(client, "502 I am so dumb I only understand HELO and QUIT")
diff --git a/test/rails_2.3.gemfile b/test/rails_2.3.gemfile
index 80aa9fc..e30fa69 100644
--- a/test/rails_2.3.gemfile
+++ b/test/rails_2.3.gemfile
@@ -13,6 +13,9 @@ gem 'rails', "~> 2.3.15"
 gem 'rdoc'
 gem 'rdoc-data'
 
+# mime-types 2.0 requires Ruby version >= 1.9.2
+gem "mime-types", "< 2.0"
+
 group :development, :test do
   if defined?(JRUBY_VERSION)
     gem 'jruby-openssl'
diff --git a/test/rails_4.1.gemfile b/test/rails_4.1.gemfile
new file mode 100644
index 0000000..b199010
--- /dev/null
+++ b/test/rails_4.1.gemfile
@@ -0,0 +1,19 @@
+# Gemfile for health_test testing
+
+source 'https://rubygems.org'
+
+ruby '1.9.3' if RUBY_VERSION < '1.9.3'
+
+gem 'rails', "~> 4.1.0"
+gem 'rake', '>= 0.8.3'
+gem "rack", '~> 1.5.2'
+
+group :development, :test do
+  if defined?(JRUBY_VERSION)
+    gem 'jruby-openssl'
+    gem 'activerecord-jdbcsqlite3-adapter'
+  else
+    gem 'sqlite3', "~> 1.3.7"
+  end
+  gem 'shoulda'
+end
diff --git a/test/setup_railsapp b/test/setup_railsapp
index 5f414f9..80f6116 100755
--- a/test/setup_railsapp
+++ b/test/setup_railsapp
@@ -164,6 +164,9 @@ then
     echo ================= Gemfile ===================
     cat Gemfile
     echo
+    echo ================= Gemfile.lock ===================
+    cat Gemfile.lock
+    echo
 else
     dest=$railsapp/vendor/plugins/health_check
     echo Installing health_check as plugin in $dest ...
diff --git a/test/test_with_railsapp b/test/test_with_railsapp
index 2ba4bc4..c866c68 100755
--- a/test/test_with_railsapp
+++ b/test/test_with_railsapp
@@ -306,6 +306,10 @@ common_tests()
     date > $custom_file
 }
 
+
+# required for rails 4.1+ in production mode
+export SECRET_KEY_BASE=cf2f49c38a3fe67416ddf680f4f3187c0fce7dd1b9b117b34d195df75b274e08a04877e23803b2fdf1aa9a655269d94bc4888aa325cf7e721cc47368cfe56a80
+
 echo ========================================================
 echo TESTING WITHOUT CATCHALL in test env
 echo ========================================================
