search for: failed_associ

Displaying 1 result from an estimated 1 matches for "failed_associ".

2007 Mar 29
21
a better "should have valid associations"
...s won''t check if you removed some associations. And it won''t check for polymorphs either.) Put this somewhere handy and require it into spec_helper. ======================================== module ActiveRecordMatchers class HaveValidAssociations def matches?(model) @failed_association = nil @model_class = model.class model.class.reflect_on_all_associations.each do |assoc| begin model.send(assoc.name, true) model.class.send(''find'', :first, :include => assoc.name) rescue ActiveRecord::EagerLoadPolymorphicEr...