Created
December 10, 2010 17:05
-
-
Save opsb/736474 to your computer and use it in GitHub Desktop.
mongoid embeds many bug with field on child
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'mongoid' | |
require 'rspec' | |
require 'method_lister' | |
Mongoid.configure do |config| | |
name = "association_bug" | |
config.master = Mongo::Connection.new.db(name) | |
end | |
class Commit | |
include Mongoid::Document | |
embeds_many :tasks | |
end | |
class Task | |
include Mongoid::Document | |
embedded_in :commit, :inverse_of => :tasks | |
field :name | |
end | |
def show_methods(object) | |
puts (object.methods.sort - Object.new.methods).join(", ") | |
end | |
describe Commit do | |
before do | |
@commit = Commit.create | |
end | |
it "passes" do | |
@commit.tasks.destroy_all | |
@commit.tasks.create :name => "test" | |
@commit.tasks.destroy_all | |
@commit.tasks.create :name => "test" | |
end | |
it "passes" do | |
@commit.tasks.destroy_all | |
@commit.tasks.create :name => "test" | |
@commit.tasks.create :name => "test" | |
@commit.tasks.create :name => "test" | |
end | |
it "fails" do | |
@commit.tasks.create :name => "test" | |
@commit.tasks.create :name => "test" | |
@commit.tasks.destroy_all | |
@commit.tasks.create :name => "test" # this call fails | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment