Sha256: 8fe58349a4085dfa3536a2c38434f3b3ca8f42c91776019dbd34c99859738db7

Contents?: true

Size: 1.45 KB

Versions: 108

Compression:

Stored size: 1.45 KB

Contents

FactoryBot.define do
  factory :page do
    title       { 'Page' }
    breadcrumb  { title }
    slug        { title.slugify }

    trait :with_parts do
      page_parts { [FactoryBot.create(:page_part, name: 'body')] }
    end

    trait :with_children do
      children { [FactoryBot.create(:page, :with_parts)] }
    end

    factory :page_with_layout do
      layout
    end

    factory :page_with_page_parts do
      page_parts
    end

    factory :file_not_found_page, class: FileNotFoundPage do
    end

    factory :parent do

    end

    factory :published_page do
      status_id { Status[:published].id }

      factory :article do
        title { generate(:article_title)}
        slug { generate(:article_slug)}
      end

      factory :page_with_body_page_part do
        after(:create) { |page| page.parts.create(name: 'body', content: "#{page.title} body.") }
      end

      factory :page_with_body_and_sidebar_parts do
        after(:create) { |page| page.parts.create(name: 'body', content: "#{page.title} body.") }
        after(:create) { |page| page.parts.create(name: 'sidebar', content: "#{page.title} sidebar.") }
      end
    end

    factory :home do |home|
      title { 'Home' }
      slug { '/' }
      status_id { Status[:published].id }
      parent_id { nil }
    end

  end

  sequence :article_slug do |n|
    "article#{('-' + n.to_s) unless n == 1 }"
  end
  sequence :article_title do |n|
    "Article#{(' ' + n.to_s) unless n == 1 }"
  end
end

Version data entries

108 entries across 108 versions & 1 rubygems

Version Path
trusty-cms-7.0.9.1 spec/factories/page.rb
trusty-cms-7.0.11 spec/factories/page.rb
trusty-cms-7.0.10 spec/factories/page.rb
trusty-cms-7.0.9 spec/factories/page.rb
trusty-cms-7.0.8 spec/factories/page.rb
trusty-cms-7.0.7 spec/factories/page.rb
trusty-cms-7.0.6 spec/factories/page.rb
trusty-cms-7.0.5 spec/factories/page.rb
trusty-cms-7.0.4 spec/factories/page.rb
trusty-cms-7.0.3 spec/factories/page.rb
trusty-cms-6.3.1 spec/factories/page.rb
trusty-cms-7.0.2 spec/factories/page.rb
trusty-cms-7.0.1 spec/factories/page.rb
trusty-cms-7.0.0 spec/factories/page.rb
trusty-cms-6.3 spec/factories/page.rb
trusty-cms-6.2.1 spec/factories/page.rb
trusty-cms-6.2.2.1 spec/factories/page.rb
trusty-cms-6.2.0 spec/factories/page.rb
trusty-cms-6.1.2 spec/factories/page.rb
trusty-cms-6.1.1 spec/factories/page.rb