diff --git a/lib/mongo/repl_set_connection.rb b/lib/mongo/repl_set_connection.rb index 4aa10b8..d818a07 100644 --- a/lib/mongo/repl_set_connection.rb +++ b/lib/mongo/repl_set_connection.rb @@ -476,7 +476,10 @@ module Mongo # Refresh @refresh_mode = opts.fetch(:refresh_mode, false) - @refresh_interval = opts[:refresh_interval] || 90 + @refresh_interval = opts.fetch(:refresh_interval, 90) + if @refresh_mode && @refresh_interval < 60 + @refresh_interval = 60 + end if @refresh_mode == :async warn ":async refresh mode has been deprecated. Refresh diff --git a/test/unit/connection_test.rb b/test/unit/connection_test.rb index 2db2e26..1572cb7 100644 --- a/test/unit/connection_test.rb +++ b/test/unit/connection_test.rb @@ -41,6 +41,12 @@ class ConnectionTest < Test::Unit::TestCase end context "given a replica set" do + should "enforce a minimum refresh_interval" do + @conn = ReplSetConnection.new(['localhost:27017'], + :connect => false, :refresh_mode => :sync, :refresh_interval => 10) + assert_equal 60, @conn.refresh_interval + end + should "warn if invalid options are specified" do conn = ReplSetConnection.allocate opts = {:connect => false}