Commit 2af8ad0f authored by Alex Kalderimis's avatar Alex Kalderimis

Allow wiki page attributes to be passed separately

parent c16351a7
...@@ -5,17 +5,22 @@ require 'ostruct' ...@@ -5,17 +5,22 @@ require 'ostruct'
FactoryBot.define do FactoryBot.define do
factory :wiki_page do factory :wiki_page do
transient do transient do
title { generate(:wiki_page_title) }
content { 'Content for wiki page' }
format { 'markdown' }
project { create(:project) }
attrs do attrs do
{ {
title: 'Title.with.dot', title: title,
content: 'Content for wiki page', content: content,
format: 'markdown' format: format
} }
end end
end end
page { OpenStruct.new(url_path: 'some-name') } page { OpenStruct.new(url_path: 'some-name') }
association :wiki, factory: :project_wiki, strategy: :build wiki { build(:project_wiki, project: project) }
initialize_with { new(wiki, page) } initialize_with { new(wiki, page) }
before(:create) do |page, evaluator| before(:create) do |page, evaluator|
...@@ -26,4 +31,30 @@ FactoryBot.define do ...@@ -26,4 +31,30 @@ FactoryBot.define do
page.create page.create
end end
end end
factory :wiki_page_meta, class: 'WikiPage::Meta' do
title { generate(:wiki_page_title) }
project { create(:project) }
trait :for_wiki_page do
transient do
wiki_page { create(:wiki_page, project: project) }
end
initialize_with { wiki_page.meta }
end
end
factory :wiki_page_slug, class: 'WikiPage::Slug' do
wiki_page_meta { create(:wiki_page_meta) }
slug { generate(:sluggified_title) }
canonical { false }
trait :canonical do
canonical { true }
end
end
sequence(:wiki_page_title) { |n| "Page #{n}" }
sequence(:sluggified_title) { |n| "slug-#{n}" }
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment