Skip to content

Instantly share code, notes, and snippets.

@michaelglass
Created August 23, 2011 19:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelglass/1166234 to your computer and use it in GitHub Desktop.
Save michaelglass/1166234 to your computer and use it in GitHub Desktop.
test to reproduce stack level too deep in mongo_mapper
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