From 955752150494f520beccc658d050172d64b7d989 Mon Sep 17 00:00:00 2001 From: Durran Jordan Date: Wed, 21 Sep 2011 13:34:15 +0200 Subject: [PATCH] Don't add replica set options to host options in place. Fixes #1272. --- lib/mongoid/config/replset_database.rb | 4 ++-- spec/functional/mongoid/config/replset_database_spec.rb | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/mongoid/config/replset_database.rb b/lib/mongoid/config/replset_database.rb index 6ed432f2bf..97dd7791d2 100644 --- a/lib/mongoid/config/replset_database.rb +++ b/lib/mongoid/config/replset_database.rb @@ -14,14 +14,14 @@ class ReplsetDatabase < Hash # # @since 2.0.0.rc.5 def configure - # yes, construction is weird but the driver wants + # yes, construction is weird but the driver wants # "A list of host-port pairs ending with a hash containing any options" # mongo likes symbols options = self.inject({ :logger => Mongoid::Logger.new }) do |memo, (k, v)| memo[k.to_sym] = v memo end - connection = Mongo::ReplSetConnection.new(*(hosts << options)) + connection = Mongo::ReplSetConnection.new(*(hosts.clone << options)) if authenticating? connection.add_auth(database, username, password) diff --git a/spec/functional/mongoid/config/replset_database_spec.rb b/spec/functional/mongoid/config/replset_database_spec.rb index 1aad4968d1..974e504411 100644 --- a/spec/functional/mongoid/config/replset_database_spec.rb +++ b/spec/functional/mongoid/config/replset_database_spec.rb @@ -49,6 +49,12 @@ it "sets up the default mongoid logger" do replica_set.logger.should eq(Mongoid::Config.logger) end + + it "does not modify the options in place" do + options["test"]["hosts"].should eq( + [["localhost", 27017], ["localhost", 27017]] + ) + end end context "with authentication details" do