summaryrefslogtreecommitdiff
path: root/spec/factories/wiki_pages.rb
blob: ae257d769e894380286209e51098747817459cde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
require 'ostruct'

FactoryBot.define do
  factory :wiki_page do
    transient do
      attrs do
        {
          title: 'Title.with.dot',
          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