Sha256: 2615df09f437dbb1545aee01d6e2e96b70c599a0fd4d7d54167b4dd543518964

Contents?: true

Size: 1.29 KB

Versions: 5

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

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

5 entries across 5 versions & 1 rubygems

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