thoughtbot/factory_girl — Issue #280: :parent seems to be ignored for nested factory definitions
Author: ryanfields
Created: 2012-01-22 22:06:04+00:00
State: open

I had an issue where it appeared that callbacks weren't being inherited on my child factories, but after some investigation the issue appears to be that :parent just gets ignored if a factory is defined within another factory block.

```ruby
FactoryGirl.define do
factory :event do
name "My Event"
occurs_at Date.today

factory :structured_event do
after_create do |e|
e.add_station 'Sales Booth'
end
end

factory :staffed_event, :parent => :structured_event do
after_create do |e|
station = e.stations.find_by_name("Sales Booth")
e.add_worker(FactoryGirl.create(:worker), station)
end
end
end
end
```

When running my tests, it appears that :staffed_event inherits from :event instead of :structured_event. At the very least, it seems to be missing the callback from :structured_event.

I probably shouldn't be mixing declaration styles like this, but if I choose to do so anyway, I'd expect :parent to be honored.