Sha256: 62800e5800dce767afb3380570b28af2e972370a8e7a4ce4d2905bc6d576f25f

Contents?: true

Size: 1.64 KB

Versions: 8

Compression:

Stored size: 1.64 KB

Contents

FactoryBot.define do
  factory :account, class: Pageflow::Account do
    name { 'Account Name' }

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

    trait(:with_first_paged_entry_template) do
      after(:create) do |account, _|
        create(:entry_template, account: account, entry_type: 'paged')
      end
    end

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

      with_feature { nil }
      without_feature { nil }
    end

    after(:create) do |account, evaluator|
      create(:membership,
             entity: account,
             user: evaluator.with_member,
             role: :member) if evaluator.with_member
      create(:membership,
             entity: account,
             user: evaluator.with_previewer,
             role: :previewer) if evaluator.with_previewer
      create(:membership,
             entity: account,
             user: evaluator.with_editor,
             role: :editor) if evaluator.with_editor
      create(:membership,
             entity: account,
             user: evaluator.with_publisher,
             role: :publisher) if evaluator.with_publisher
      create(:membership,
             entity: account,
             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,
                                           evaluator.without_feature => false)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pageflow-15.8.0 spec/factories/accounts.rb
pageflow-15.7.1 spec/factories/accounts.rb
pageflow-15.7.0 spec/factories/accounts.rb
pageflow-15.6.1 spec/factories/accounts.rb
pageflow-15.6.0 spec/factories/accounts.rb
pageflow-15.5.0 spec/factories/accounts.rb
pageflow-15.4.0 spec/factories/accounts.rb
pageflow-15.3.0 spec/factories/accounts.rb