FactoryGirl.define do
  factory :topic, :class => Forem::Topic do |t|
    t.subject "FIRST TOPIC"
    t.forum {|f| f.association(:forum) }
    t.user {|u| u.association(:user) }
    t.posts { |p| [p.association(:post)]}

    trait :approved do
      after_create { |topic| topic.approve! }
    end

    factory :approved_topic, :traits => [:approved]
  end
end

FactoryGirl.define do
  factory :topic, :class => Forem::Topic do |t|
    t.subject "FIRST TOPIC"
    t.forum {|f| f.association(:forum) }
    t.user {|u| u.association(:user) }
    t.posts_attributes { [Factory.attributes_for(:post)] }

    trait :approved do
      after_create { |topic| topic.approve! }
    end

    factory :approved_topic, :traits => [:approved]
  end
end

Send through post attributes using posts_attributes when creating a topic
Send through post attributes using posts_attributes when creating a topic

This ensures that when we use factories that the topics+posts are created identically to how they're created inside the application
