Skip to content

Commit

Permalink
Updated to 0.14 version of mongo ruby driver.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnunemaker committed Aug 29, 2009
1 parent 711c6a3 commit 30d5fa9
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ begin
gem.rubyforge_project = "mongomapper"

gem.add_dependency('activesupport')
gem.add_dependency('mongodb-mongo', '0.11.1')
gem.add_dependency('mongodb-mongo', '0.14')
gem.add_dependency('jnunemaker-validatable', '1.7.2')

gem.add_development_dependency('mocha', '0.9.4')
Expand Down
1 change: 0 additions & 1 deletion bin/mmconsole
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ IRB.conf[:MAIN_CONTEXT] = irb.context

irb.context.evaluate("require 'irb/completion'", 0)
irb.context.evaluate(%@
include XGen::Mongo::Driver
include MongoMapper
MongoMapper.database = "mmtest"
Expand Down
6 changes: 3 additions & 3 deletions lib/mongomapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
require 'rubygems'

gem 'activesupport'
gem 'mongodb-mongo', '0.11.1'
gem 'mongodb-mongo', '0.14'
gem 'jnunemaker-validatable', '1.7.2'

require 'activesupport'
# require 'activesupport'
require 'mongo'
require 'validatable'

Expand Down Expand Up @@ -54,7 +54,7 @@ def initialize(document)
end

def self.connection
@@connection ||= XGen::Mongo::Driver::Mongo.new
@@connection ||= Mongo::Connection.new
end

def self.connection=(new_connection)
Expand Down
6 changes: 3 additions & 3 deletions lib/mongomapper/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ def all(options={})

def find_by_id(id)
criteria = FinderOptions.to_mongo_criteria(:_id => id)
if doc = collection.find_first(criteria)
if doc = collection.find_one(criteria)
new(doc)
end
end

def count(conditions={})
collection.count(FinderOptions.to_mongo_criteria(conditions))
collection.find(FinderOptions.to_mongo_criteria(conditions)).count
end

def create(*docs)
Expand Down Expand Up @@ -320,7 +320,7 @@ def create

def assign_id
if read_attribute(:_id).blank?
write_attribute(:_id, XGen::Mongo::Driver::ObjectID.new.to_s)
write_attribute(:_id, Mongo::ObjectID.new.to_s)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/mongomapper/embedded_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def initialize(attrs={})
end

if self.class.embeddable? && read_attribute(:_id).blank?
write_attribute :_id, XGen::Mongo::Driver::ObjectID.new.to_s
write_attribute :_id, Mongo::ObjectID.new.to_s
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/functional/test_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def setup

context "Loading a document from the database with keys that are not defined" do
setup do
@id = XGen::Mongo::Driver::ObjectID.new.to_s
@id = Mongo::ObjectID.new.to_s
@document.collection.insert({
:_id => @id,
:first_name => 'John',
Expand Down
8 changes: 4 additions & 4 deletions test/unit/test_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ class DocumentTest < Test::Unit::TestCase
end

should "have a connection" do
@document.connection.should be_instance_of(XGen::Mongo::Driver::Mongo)
@document.connection.should be_instance_of(Mongo::Connection)
end

should "allow setting different connection without affecting the default" do
conn = XGen::Mongo::Driver::Mongo.new
conn = Mongo::Connection.new
@document.connection conn
@document.connection.should == conn
@document.connection.should_not == MongoMapper.connection
Expand All @@ -43,13 +43,13 @@ class Item
include MongoMapper::Document
end

Item.collection.should be_instance_of(XGen::Mongo::Driver::Collection)
Item.collection.should be_instance_of(Mongo::Collection)
Item.collection.name.should == 'items'
end

should "allow setting the collection name" do
@document.collection('foobar')
@document.collection.should be_instance_of(XGen::Mongo::Driver::Collection)
@document.collection.should be_instance_of(Mongo::Collection)
@document.collection.name.should == 'foobar'
end
end # Document class
Expand Down
6 changes: 3 additions & 3 deletions test/unit/test_mongomapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ class Address; end

class MongoMapperTest < Test::Unit::TestCase
should "be able to write and read connection" do
conn = XGen::Mongo::Driver::Mongo.new
conn = Mongo::Connection.new
MongoMapper.connection = conn
MongoMapper.connection.should == conn
end

should "default connection to new mongo ruby driver" do
MongoMapper.connection = nil
MongoMapper.connection.should be_instance_of(XGen::Mongo::Driver::Mongo)
MongoMapper.connection.should be_instance_of(Mongo::Connection)
end

should "be able to write and read default database" do
MongoMapper.database = DefaultDatabase
MongoMapper.database.should be_instance_of(XGen::Mongo::Driver::DB)
MongoMapper.database.should be_instance_of(Mongo::DB)
MongoMapper.database.name.should == DefaultDatabase
end

Expand Down

0 comments on commit 30d5fa9

Please sign in to comment.