unit testing - Rails has_many and belongs_to on same model -


i have school model has_many :users. but, each school has primary_user. here model:

 has_many :users  belongs_to :primarycontact, :class_name => "user" 

this works fine in my production , dev app, raises stack level errors in factorygirl while testing. associations smell bad me, , stack level errors in testing indicate me there better way.

is there better way? ...any ideas why factorygirl struggling it?

my factory

  factorygirl.define     factory :school       name "test school"       association :primarycontact, factory: :user, name: "primary user"     end   end 

stack trace

  userdoc     test_0001_must valid 0:00:09.143 error       stack level deep       exception `systemstackerror' at: 

so, error originating in third model, userdoc. when factory creates userdoc, creates user, .. user must belong school factory creates school. but, when school factory gets triggered tries create user because of primarycontact association.


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -