public

test to reproduce stack level too deep in mongo_mapper

  • Download Gist
test_stack_level_too_deep.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.