4af9d592c5
I've followed the [upgrade guide](https://github.com/thoughtbot/factory_bot/blob/4-9-0-stable/UPGRADE_FROM_FACTORY_GIRL.md) and ran these two commands: ``` grep -e FactoryGirl **/*.rake **/*.rb -s -l | xargs sed -i "" "s|FactoryGirl|FactoryBot|" grep -e factory_girl **/*.rake **/*.rb -s -l | xargs sed -i "" "s|factory_girl|factory_bot|" ``` Signed-off-by: Rémy Coutable <remy@rymai.me>
27 lines
546 B
Ruby
27 lines
546 B
Ruby
require 'ostruct'
|
|
|
|
FactoryBot.define do
|
|
factory :wiki_page do
|
|
transient do
|
|
attrs do
|
|
{
|
|
title: 'Title',
|
|
content: 'Content for wiki page',
|
|
format: 'markdown'
|
|
}
|
|
end
|
|
end
|
|
|
|
page { OpenStruct.new(url_path: 'some-name') }
|
|
association :wiki, factory: :project_wiki, strategy: :build
|
|
initialize_with { new(wiki, page, true) }
|
|
|
|
before(:create) do |page, evaluator|
|
|
page.attributes = evaluator.attrs
|
|
end
|
|
|
|
to_create do |page|
|
|
page.create
|
|
end
|
|
end
|
|
end
|