Sha256: 37a550174c2a9621995b85917205f54f64b1f6cbde00e88434cae6a3ba0e4cfc

Contents?: true

Size: 1.86 KB

Versions: 11

Compression:

Stored size: 1.86 KB

Contents

module Pageflow
  FactoryBot.define do
    sequence :title do |n|
      "Entry #{n}"
    end

    factory :entry, class: Entry do
      title

      account

      after(:build) do |entry|
        entry.theming ||= entry.account.default_theming
      end

      transient do
        with_previewer { nil }
        with_editor { nil }
        with_publisher { nil }
        with_manager { nil }

        with_feature { nil }
      end

      after(:create) do |entry, evaluator|
        create(:membership,
               entity: entry,
               user: evaluator.with_previewer,
               role: :previewer) if evaluator.with_previewer
        create(:membership,
               entity: entry,
               user: evaluator.with_editor,
               role: :editor) if evaluator.with_editor
        create(:membership,
               entity: entry,
               user: evaluator.with_publisher,
               role: :publisher) if evaluator.with_publisher
        create(:membership,
               entity: entry,
               user: evaluator.with_manager,
               role: :manager) if evaluator.with_manager
      end

      after(:build) do |entry, evaluator|
        entry.features_configuration =
          entry.features_configuration.merge(evaluator.with_feature => true)
      end

      trait :published do
        transient do
          published_revision_attributes { {} }
        end

        after(:create) do |entry, evaluator|
          create(:revision, :published, evaluator.published_revision_attributes.merge(entry: entry))
        end
      end

      trait :published_with_password do
        after(:create) do |entry, _evaluator|
          create(:revision, :published, entry: entry, password_protected: true)
        end
      end

      trait :with_highdef_video_encoding do
        feature_states { {'highdef_video_encoding' => true} }
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
pageflow-14.0.0.beta1 spec/factories/entries.rb
pageflow-13.6.0 spec/factories/entries.rb
pageflow-13.5.0 spec/factories/entries.rb
pageflow-13.4.0 spec/factories/entries.rb
pageflow-13.3.0 spec/factories/entries.rb
pageflow-13.2.0 spec/factories/entries.rb
pageflow-13.1.0 spec/factories/entries.rb
pageflow-13.0.0 spec/factories/entries.rb
pageflow-13.0.0.rc1 spec/factories/entries.rb
pageflow-13.0.0.beta7 spec/factories/entries.rb
pageflow-13.0.0.beta6 spec/factories/entries.rb