Sha256: d717e08288f60625b30850c481a8bc742922956c6f24ad1f83eaef5a9282ed06

Contents?: true

Size: 1.13 KB

Versions: 50

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

FactoryBot.define do
  factory :user do
    sequence(:email) { |n| "user#{n}@example.com" }
    password { 'insecure' }
    factory :site_admin do
      after(:create) do |user, _evaluator|
        user.roles.create role: 'admin', resource: Spotlight::Site.instance
      end
    end

    factory :named_exhibit_roles do
      transient do
        exhibit { FactoryBot.create(:exhibit) }
        role { nil }
      end

      after(:create) do |user, evaluator|
        user.roles.create role: evaluator.role, resource: evaluator.exhibit if evaluator.role
      end

      factory :exhibit_admin do
        transient do
          role { 'admin' }
        end
      end

      factory :exhibit_curator do
        transient do
          role { 'curator' }
        end
      end
    end

    trait :with_exhibit_role do
      transient do
        exhibit { FactoryBot.create(:exhibit) }
        role { nil }
      end

      after(:create) do |user, evaluator|
        user.roles.create role: evaluator.role, resource: evaluator.exhibit if evaluator.role
      end
    end

    factory :exhibit_visitor do
    end
  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
blacklight-spotlight-4.7.0 spec/factories/users.rb
blacklight-spotlight-4.6.1 spec/factories/users.rb
blacklight-spotlight-4.6.0 spec/factories/users.rb
blacklight-spotlight-4.5.0 spec/factories/users.rb
blacklight-spotlight-4.4.0 spec/factories/users.rb
blacklight-spotlight-4.3.6 spec/factories/users.rb
blacklight-spotlight-4.3.5 spec/factories/users.rb
blacklight-spotlight-4.3.4 spec/factories/users.rb
blacklight-spotlight-4.3.3 spec/factories/users.rb
blacklight-spotlight-4.3.2 spec/factories/users.rb
blacklight-spotlight-4.3.1 spec/factories/users.rb
blacklight-spotlight-4.3.0 spec/factories/users.rb
blacklight-spotlight-4.2.0 spec/factories/users.rb
blacklight-spotlight-4.1.2 spec/factories/users.rb
blacklight-spotlight-4.1.1 spec/factories/users.rb
blacklight-spotlight-4.1.0 spec/factories/users.rb
blacklight-spotlight-4.0.3 spec/factories/users.rb
blacklight-spotlight-4.0.2 spec/factories/users.rb
blacklight-spotlight-4.0.1 spec/factories/users.rb
blacklight-spotlight-4.0.0 spec/factories/users.rb