Sha256: f5f3a65e94612d0312f6edfcbbfd584313f27101f85578a725b9ca702d918d9d

Contents?: true

Size: 329 Bytes

Versions: 5

Compression:

Stored size: 329 Bytes

Contents

FactoryGirl.define do
  [:post, :comment].each do |type|
    factory type do
      transient { author nil }

      before(:create) do |record, evaluator|
        if evaluator.author
          author = Author.find_or_create_by(name: evaluator.author)
          record.author_id = author.id
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
repor-0.0.5 spec/factories/factories.rb
repor-0.0.4 spec/factories/factories.rb
repor-0.0.3 spec/factories/factories.rb
repor-0.0.2 spec/factories/factories.rb
repor-0.0.1 spec/factories/factories.rb