Sha256: aab6606b342c21cafb008acb4fc9200c20bb7fe256774d05e5ac0c8160253b4a

Contents?: true

Size: 1.72 KB

Versions: 8

Compression:

Stored size: 1.72 KB

Contents

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

    after(:build) do |account, evaluator|
      account.default_site ||=
        build(:site, account: account, **evaluator.default_site_attributes)
    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 }

      default_site_attributes { {} }
    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-17.0.4 spec/factories/accounts.rb
pageflow-17.0.3 spec/factories/accounts.rb
pageflow-17.0.2 spec/factories/accounts.rb
pageflow-17.0.1 spec/factories/accounts.rb
pageflow-17.0.0 spec/factories/accounts.rb
pageflow-16.2.0 spec/factories/accounts.rb
pageflow-16.1.0 spec/factories/accounts.rb
pageflow-16.0.0 spec/factories/accounts.rb