Sha256: 419af80c7dc2d4e889358062198eefb8d3b8e4c7cb44ae7d2bb49d9f702f319e

Contents?: true

Size: 1.29 KB

Versions: 13

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

FactoryBot.define do
  factory :g5_authenticatable_location_user, parent: :g5_authenticatable_user do
    transient do
      locations nil
      location_count 1
      role_factory :g5_authenticatable_location_role
    end

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

      user.roles << if evaluator.locations
                      evaluator.locations.collect do |location|
                        create(evaluator.role_factory, resource: location)
                      end
                    else
                      user.roles << create_list(evaluator.role_factory,
                                                evaluator.location_count)
                    end
    end
  end

  factory :g5_authenticatable_location_admin,
          parent: :g5_authenticatable_location_user do
    transient do
      role_factory :g5_authenticatable_location_admin_role
    end
  end

  factory :g5_authenticatable_location_editor,
          parent: :g5_authenticatable_location_user do
    transient do
      role_factory :g5_authenticatable_location_editor_role
    end
  end

  factory :g5_authenticatable_location_viewer,
          parent: :g5_authenticatable_location_user do
    transient do
      role_factory :g5_authenticatable_location_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/location_users.rb
g5_authenticatable-1.1.4.rc.3 lib/g5_authenticatable/test/factories/location_users.rb
g5_authenticatable-1.1.4.rc.2 lib/g5_authenticatable/test/factories/location_users.rb
g5_authenticatable-1.1.4.rc.1 lib/g5_authenticatable/test/factories/location_users.rb
g5_authenticatable-1.1.2 lib/g5_authenticatable/test/factories/location_users.rb
g5_authenticatable-1.1.2.pre.1 lib/g5_authenticatable/test/factories/location_users.rb
g5_authenticatable-1.1.2.rc.5 lib/g5_authenticatable/test/factories/location_users.rb
g5_authenticatable-1.1.2.rc.4 lib/g5_authenticatable/test/factories/location_users.rb
g5_authenticatable-1.1.2.rc.3 lib/g5_authenticatable/test/factories/location_users.rb
g5_authenticatable-1.1.2.rc.2 lib/g5_authenticatable/test/factories/location_users.rb
g5_authenticatable-1.1.2.rc.1 lib/g5_authenticatable/test/factories/location_users.rb
g5_authenticatable-1.1.1 lib/g5_authenticatable/test/factories/location_users.rb
g5_authenticatable-1.1.0 lib/g5_authenticatable/test/factories/location_users.rb