Sha256: 82c32805c8d09373fd85216c3c90fadc87ad8151887368a31b3faa276f4beab9

Contents?: true

Size: 614 Bytes

Versions: 12

Compression:

Stored size: 614 Bytes

Contents

FactoryBot.define do
  factory :author do
    name { Faker::Name.name }
  end

  factory :comment 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

  
  factory :post do
    status { :published }
    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

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
active_reporter-0.6.5 spec/factories/factories.rb
active_reporter-0.6.4 spec/factories/factories.rb
active_reporter-0.6.3 spec/factories/factories.rb
active_reporter-0.6.2 spec/factories/factories.rb
active_reporter-0.6.1 spec/factories/factories.rb
active_reporter-0.6.0 spec/factories/factories.rb
active_reporter-0.5.13 spec/factories/factories.rb
active_reporter-0.5.12 spec/factories/factories.rb
active_reporter-0.5.11 spec/factories/factories.rb
active_reporter-0.5.10 spec/factories/factories.rb
active_reporter-0.5.9 spec/factories/factories.rb
active_reporter-0.5.8 spec/factories/factories.rb