Sha256: 827d053f2e5ad2b849e6934d645d477ceb679aa71fc7ecca82730b3be343097f

Contents?: true

Size: 1.23 KB

Versions: 13

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

FactoryBot.define do
  factory :g5_authenticatable_client_user, parent: :g5_authenticatable_user do
    transient do
      clients nil
      client_count 1
      role_factory :g5_authenticatable_client_role
    end

    after(:create) do |user, evaluator|
      user.roles.clear

      user.roles << if evaluator.clients
                      evaluator.clients.collect do |client|
                        create(evaluator.role_factory, resource: client)
                      end
                    else
                      create_list(evaluator.role_factory,
                                  evaluator.client_count)
                    end
    end
  end

  factory :g5_authenticatable_client_admin,
          parent: :g5_authenticatable_client_user do
    transient do
      role_factory :g5_authenticatable_client_admin_role
    end
  end

  factory :g5_authenticatable_client_editor,
          parent: :g5_authenticatable_client_user do
    transient do
      role_factory :g5_authenticatable_client_editor_role
    end
  end

  factory :g5_authenticatable_client_viewer,
          parent: :g5_authenticatable_client_user do
    transient do
      role_factory :g5_authenticatable_client_viewer_role
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
g5_authenticatable-1.1.4 lib/g5_authenticatable/test/factories/client_users.rb
g5_authenticatable-1.1.4.rc.3 lib/g5_authenticatable/test/factories/client_users.rb
g5_authenticatable-1.1.4.rc.2 lib/g5_authenticatable/test/factories/client_users.rb
g5_authenticatable-1.1.4.rc.1 lib/g5_authenticatable/test/factories/client_users.rb
g5_authenticatable-1.1.2 lib/g5_authenticatable/test/factories/client_users.rb
g5_authenticatable-1.1.2.pre.1 lib/g5_authenticatable/test/factories/client_users.rb
g5_authenticatable-1.1.2.rc.5 lib/g5_authenticatable/test/factories/client_users.rb
g5_authenticatable-1.1.2.rc.4 lib/g5_authenticatable/test/factories/client_users.rb
g5_authenticatable-1.1.2.rc.3 lib/g5_authenticatable/test/factories/client_users.rb
g5_authenticatable-1.1.2.rc.2 lib/g5_authenticatable/test/factories/client_users.rb
g5_authenticatable-1.1.2.rc.1 lib/g5_authenticatable/test/factories/client_users.rb
g5_authenticatable-1.1.1 lib/g5_authenticatable/test/factories/client_users.rb
g5_authenticatable-1.1.0 lib/g5_authenticatable/test/factories/client_users.rb