Sha256: 1c61997a43cc347ed5f8985e067240cd51500ffff5d65e4bc12f2c5404dff29d

Contents?: true

Size: 1.23 KB

Versions: 5

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

FactoryGirl.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

5 entries across 5 versions & 1 rubygems

Version Path
g5_authenticatable-1.0.0 lib/g5_authenticatable/test/factories/client_users.rb
g5_authenticatable-1.0.0.pre.4 lib/g5_authenticatable/test/factories/client_users.rb
g5_authenticatable-1.0.0.pre.3 lib/g5_authenticatable/test/factories/client_users.rb
g5_authenticatable-1.0.0.pre.2 lib/g5_authenticatable/test/factories/client_users.rb
g5_authenticatable-1.0.0.pre.1 lib/g5_authenticatable/test/factories/client_users.rb