Skip to content

Commit

Permalink
Don't add replica set options to host options in place. Fixes #1272.
Browse files Browse the repository at this point in the history
  • Loading branch information
durran committed Sep 21, 2011
1 parent 60c0225 commit 9557521
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/mongoid/config/replset_database.rb
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions spec/functional/mongoid/config/replset_database_spec.rb
Expand Up @@ -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
Expand Down

0 comments on commit 9557521

Please sign in to comment.