Created
August 23, 2011 19:28
test to reproduce stack level too deep in mongo_mapper
This file contains hidden or 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 'test_helper' | |
require 'models' | |
class StackLevelTooDeepTest < Test::Unit::TestCase | |
def setup | |
@klass = Doc('Person') do | |
key :name, String | |
end | |
@pet_klass = EDoc('Pet') do | |
key :name, String | |
end | |
@klass.many :pets, :class => @pet_klass | |
@address_class = EDoc('Address') do | |
key :city, String | |
key :state, String | |
end | |
end | |
should "be able to save many embedded documents" do | |
setup | |
person = @klass.create | |
1000.times do | |
person.pets << @pet_klass.new(:name => 'sparky') | |
end | |
failed = false | |
begin | |
person.save | |
rescue SystemStackError => e | |
failed = true | |
#silently swallow up error... | |
end | |
person.reload | |
person.should_not be_new | |
person.pets.count.should == 1000 | |
person.pets.last.should_not be_new | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment