tags:

views:

82

answers:

1
#test/factories.rb

Factory.define :estado do |estado|
  estado.nombre "Distrito Federal"
end

Factory.define :municipio do |municipio|
  municipio.nombre "Cuauhtémoc"
  municipio.estado { |estado| estado.association(:estado) }
end

Factory.define :colonia do |colonia|
  colonia.nombre "Condesa"
  colonia.municipio { |municipio| municipio.association(:municipio) }
end

#test/units/user_test.rb
test "Whats wrong with this"
    assert(Factory.create(:colonia).id != 0)
end

The test fails miserably because Factory.create(:colonia) ALWAYS create a Colonia object with and id equals 0!!! @_@

Why is this factory creating objects with id 0?

+1  A: 

It looks like a problem with the structure of your DB to me.

Is the id column in your 'colonias' table set to autoincrement?

Mr. Matt
I'm SO ashamed now...
Erik Escobedo