Sha256: 814ced4b6d4817a87c7d0737e38a66e595b07690a44d23f4268322bf77069886

Contents?: true

Size: 1.16 KB

Versions: 63

Compression:

Stored size: 1.16 KB

Contents

module Pageflow
  FactoryBot.define do
    factory :membership, class: Membership do
      user
      association :entity, factory: :entry
      role { :previewer }
      before(:create) do |membership|
        if membership.entity_type != 'Pageflow::Account' &&
           !membership.user.accounts.include?(membership.entity.account) &&
           !membership.entity.account.nil?
          create(:membership,
                 user: membership.user,
                 entity: membership.entity.account,
                 role: :member)
        end
      end
    end

    factory :entry_membership, class: Membership do
      user
      association :entity, factory: :entry
      role { :previewer }
      before(:create) do |membership|
        if !membership.user.accounts.include?(membership.entity.account) &&
           !membership.entity.account.nil?
          create(:membership,
                 user: membership.user,
                 entity: membership.entity.account,
                 role: :member)
        end
      end
    end

    factory :account_membership, class: Membership do
      user
      association :entity, factory: :account
      role { :member }
    end
  end
end

Version data entries

63 entries across 63 versions & 1 rubygems

Version Path
pageflow-17.0.4 spec/factories/memberships.rb
pageflow-17.0.3 spec/factories/memberships.rb
pageflow-17.0.2 spec/factories/memberships.rb
pageflow-17.0.1 spec/factories/memberships.rb
pageflow-17.0.0 spec/factories/memberships.rb
pageflow-16.2.0 spec/factories/memberships.rb
pageflow-16.1.0 spec/factories/memberships.rb
pageflow-16.0.0 spec/factories/memberships.rb
pageflow-15.8.0 spec/factories/memberships.rb
pageflow-14.5.2 spec/factories/memberships.rb
pageflow-15.7.1 spec/factories/memberships.rb
pageflow-15.7.0 spec/factories/memberships.rb
pageflow-15.6.1 spec/factories/memberships.rb
pageflow-15.6.0 spec/factories/memberships.rb
pageflow-15.5.0 spec/factories/memberships.rb
pageflow-15.4.0 spec/factories/memberships.rb
pageflow-15.3.0 spec/factories/memberships.rb
pageflow-15.2.2 spec/factories/memberships.rb
pageflow-15.2.1 spec/factories/memberships.rb
pageflow-15.2.0 spec/factories/memberships.rb