mirror of
https://github.com/thoughtbot/factory_bot.git
synced 2022-11-09 11:43:51 -05:00
Move factory associations logic to evaluator_class
evaluator_class contains the fully-inherited list of attributes; this includes parent classes, traits, etc. When calculating associations for an individual factory, the factory should use inheritance to build the list instead of merely accessing association attributes on itself. Closes #293
This commit is contained in:
parent
852eea84ff
commit
6cddb37ecb
3 changed files with 1 additions and 4 deletions
|
@ -53,7 +53,7 @@ module FactoryGirl
|
|||
end
|
||||
|
||||
def associations
|
||||
parent.associations + attributes.associations
|
||||
evaluator_class.attribute_list.associations
|
||||
end
|
||||
|
||||
# Names for this factory, including aliases.
|
||||
|
|
|
@ -7,7 +7,6 @@ module FactoryGirl
|
|||
end
|
||||
|
||||
delegate :defined_traits, :callbacks, :attributes, :constructor, :to => :definition
|
||||
delegate :associations, :to => :attributes
|
||||
|
||||
def compile; end
|
||||
def class_name; end
|
||||
|
|
|
@ -5,12 +5,10 @@ describe FactoryGirl::NullFactory do
|
|||
it { should delegate(:callbacks).to(:definition) }
|
||||
it { should delegate(:attributes).to(:definition) }
|
||||
it { should delegate(:constructor).to(:definition) }
|
||||
it { should delegate(:associations).to(:attributes) }
|
||||
|
||||
its(:compile) { should be_nil }
|
||||
its(:class_name) { should be_nil }
|
||||
its(:default_strategy) { should == :create }
|
||||
its(:attributes) { should be_an_instance_of(FactoryGirl::AttributeList) }
|
||||
its(:associations) { should be_empty }
|
||||
its(:evaluator_class) { should == FactoryGirl::Evaluator }
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue