Sha256: ac64e19f6595041b998cccdc7bd5ace30ba2d9d22f16699a121a5de16ce2c89f
Contents?: true
Size: 1.3 KB
Versions: 3
Compression:
Stored size: 1.3 KB
Contents
# frozen_string_literal: true FactoryBot.define do factory :admin_set do sequence(:title) { |n| ["Title #{n}"] } # Given the relationship between permission template and admin set, when # an admin set is created via a factory, I believe it is appropriate to go ahead and # create the corresponding permission template # # This way, we can go ahead after(:create) do |admin_set, evaluator| if evaluator.with_permission_template attributes = { source_id: admin_set.id } attributes = evaluator.with_permission_template.merge(attributes) if evaluator.with_permission_template.respond_to?(:merge) # There is a unique constraint on permission_templates.source_id; I don't want to # create a permission template if one already exists for this admin_set create(:permission_template, attributes) unless Hyrax::PermissionTemplate.find_by(source_id: admin_set.id) end end transient do # false, true, or Hash with keys for permission_template with_permission_template { false } end factory :complete_admin_set do alternative_title { ['alternative admin set title'] } creator { ['moomin', 'snufkin'] } description { ['Before a revolution happens', 'it is perceived as impossible'] } end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
hyrax-5.0.1 | lib/hyrax/specs/shared_specs/factories/admin_sets.rb |
hyrax-5.0.0 | spec/factories/admin_sets.rb |
hyrax-5.0.0.rc3 | spec/factories/admin_sets.rb |