Permalink
Browse files

Unsuccessful attempt to add id2 in the EmbeddedDocument

  • Loading branch information...
1 parent f3d74b2 commit 89fed49c0f3d5bbce38cb3721d232cb445574352 @phstc committed Jun 22, 2011
Showing with 2 additions and 45 deletions.
  1. +2 −1 lib/mongomapper_id2.rb
  2. +0 −44 test/functional/test_auto_increment.rb
View
@@ -18,6 +18,7 @@ def auto_increment! options = {:override => false}
module InstanceMethods
private
def update_auto_increment
+ puts 'VSF2---'
self.id2 = MongomapperId2::Incrementor[self.class.name].inc
end
def update_auto_increment_override
@@ -30,4 +31,4 @@ def update_auto_increment_override
end
MongoMapper::Document.plugin(MongoMapper::Plugins::AutoIncrement)
-MongoMapper::EmbeddedDocument.plugin(MongoMapper::Plugins::AutoIncrement)
+# MongoMapper::EmbeddedDocument.plugin(MongoMapper::Plugins::AutoIncrement)
@@ -1,44 +0,0 @@
-File.expand_path("../lib/mongomapper_id2.rb", __FILE__)
-
-require 'test_helper'
-require 'mongomapper_id2'
-
-class AutoIncrementTest < Test::Unit::TestCase
- context 'autoincrementing' do
- setup do
- @klass = Doc do
- key :title, String
- end
- @klass.auto_increment!
-
- @klass_override = Doc do
- key :title, String
- end
- @klass_override.auto_increment! :override => true
- end
-
- should 'set id2 on create' do
- doc = @klass.new(:title => 'The Simpsons Movie')
- doc.id2.should be(nil)
- doc.save
- doc.id2.should_not be(nil)
- id2 = doc.id2
- doc.save
- doc.id2.should eql id2
- end
-
- should 'auto increment id2' do
- doc = @klass.new(:title => 'Pirates of Silicon Valley')
- doc.save
- doc2 = @klass.new(:title => 'Tropa de Elite')
- doc2.save
- (doc.id2 + 1).should eql doc2.id2
- end
-
- should 'override id' do
- doc2 = @klass_override.new(:title => 'Tropa de Elite')
- doc2.save
- doc2.id2.to_s.should eql doc2.id
- end
- end
-end

0 comments on commit 89fed49

Please sign in to comment.