From fc4118a38856b3eb334f408a555e0dfb78520944 Mon Sep 17 00:00:00 2001 From: LaRita Robinson Date: Fri, 16 Feb 2024 17:06:55 -0600 Subject: [PATCH] Modify Collection & Admin Set Valkyrization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Addresses: ☄️ EPIC: Valkyrize Hyku scientist-softserv/hykuup_knapsack#35 valkyrize collection and admin set resources scientist-softserv/hykuup_knapsack#94 Moves away from directly using Hyrax::PcdmCollection and Hyrax::AdministrativeSet instead favoring inheriting from those (with CollectionResource and AdminSetResource). This allows for inheriting from Hyrax factories and extending them; thus bringing Hyku’s testing ecosystem closer to Hyrax. Note: There are a few of the new specs that still fail. - --- app/forms/admin_set_resource_form.rb | 5 + app/forms/collection_resource_form.rb | 9 ++ .../administrative_set_form_decorator.rb | 11 -- .../hyrax/forms/collection_form_decorator.rb | 22 --- app/helpers/shared_search_helper.rb | 27 ++-- app/indexers/admin_set_resource_indexer.rb | 4 + app/indexers/collection_resource_indexer.rb | 15 ++ ...set_decorator.rb => admin_set_resource.rb} | 6 +- app/models/collection_resource.rb | 15 ++ app/models/hyrax/pcdm_collection_decorator.rb | 14 -- app/services/roles_service.rb | 131 ++++++++++-------- app/views/hyrax/admin/users/index.html.erb | 2 +- config/initializers/hyrax.rb | 6 +- config/initializers/wings.rb | 12 +- config/metadata/collection_resource.yaml | 24 ++++ spec/forms/admin_set_resource_spec.rb | 11 ++ spec/forms/collection_resource_form_spec.rb | 13 ++ .../admin_set_resource_indexer_spec.rb | 11 ++ .../collection_resource_indexer_spec.rb | 13 ++ spec/models/admin_set_resource_spec.rb | 15 ++ ...or_spec.rb => collection_resource_spec.rb} | 2 +- spec/models/hyrax/administrative_set_spec.rb | 19 --- 22 files changed, 232 insertions(+), 155 deletions(-) create mode 100644 app/forms/admin_set_resource_form.rb create mode 100644 app/forms/collection_resource_form.rb delete mode 100644 app/forms/hyrax/forms/admin/administrative_set_form_decorator.rb delete mode 100644 app/forms/hyrax/forms/collection_form_decorator.rb create mode 100644 app/indexers/admin_set_resource_indexer.rb create mode 100644 app/indexers/collection_resource_indexer.rb rename app/models/{hyrax/administrative_set_decorator.rb => admin_set_resource.rb} (50%) create mode 100644 app/models/collection_resource.rb delete mode 100644 app/models/hyrax/pcdm_collection_decorator.rb create mode 100644 config/metadata/collection_resource.yaml create mode 100644 spec/forms/admin_set_resource_spec.rb create mode 100644 spec/forms/collection_resource_form_spec.rb create mode 100644 spec/indexers/admin_set_resource_indexer_spec.rb create mode 100644 spec/indexers/collection_resource_indexer_spec.rb create mode 100644 spec/models/admin_set_resource_spec.rb rename spec/models/{hyrax/pcdm_collection_decorator_spec.rb => collection_resource_spec.rb} (89%) delete mode 100644 spec/models/hyrax/administrative_set_spec.rb diff --git a/app/forms/admin_set_resource_form.rb b/app/forms/admin_set_resource_form.rb new file mode 100644 index 000000000..1eb50dd37 --- /dev/null +++ b/app/forms/admin_set_resource_form.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +class AdminSetResourceForm < Hyrax::Forms::AdministrativeSetForm + include CollectionAccessFiltering +end \ No newline at end of file diff --git a/app/forms/collection_resource_form.rb b/app/forms/collection_resource_form.rb new file mode 100644 index 000000000..1e64541af --- /dev/null +++ b/app/forms/collection_resource_form.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +# Generated via +# `rails generate hyrax:collection_resource CollectionResource` +class CollectionResourceForm < Hyrax::Forms::PcdmCollectionForm + include Hyrax::FormFields(:basic_metadata) + include Hyrax::FormFields(:collection_resource) + include CollectionAccessFiltering +end \ No newline at end of file diff --git a/app/forms/hyrax/forms/admin/administrative_set_form_decorator.rb b/app/forms/hyrax/forms/admin/administrative_set_form_decorator.rb deleted file mode 100644 index a3d35a9ab..000000000 --- a/app/forms/hyrax/forms/admin/administrative_set_form_decorator.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -module Hyrax - module Forms - module AdministrativeSetFormDecorator - include CollectionAccessFiltering - end - end -end - -Hyrax::Forms::AdministrativeSetForm.prepend(Hyrax::Forms::AdministrativeSetFormDecorator) diff --git a/app/forms/hyrax/forms/collection_form_decorator.rb b/app/forms/hyrax/forms/collection_form_decorator.rb deleted file mode 100644 index 054544c68..000000000 --- a/app/forms/hyrax/forms/collection_form_decorator.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -module Hyrax - module Forms - # Add new method to filter out access_grants for Collection Roles and Work Roles - # for Collections and AdminSets, respectively. We do this because access_grants - # for Roles should never be allowed to be removed. - # - # @see app/views/hyrax/dashboard/collections/_form_share_table.html.erb - module CollectionFormDecorator - def filter_access_grants_by_access(access) - roles_to_filter = ::RolesService::COLLECTION_ROLES + ::RolesService::WORK_ROLES - filtered_access_grants = permission_template.access_grants.select(&access) - filtered_access_grants.reject! { |ag| roles_to_filter.include?(ag.agent_id) } - - filtered_access_grants || [] - end - end - end -end - -Hyrax::Forms::CollectionForm.include(Hyrax::Forms::CollectionFormDecorator) diff --git a/app/helpers/shared_search_helper.rb b/app/helpers/shared_search_helper.rb index 7d86b9444..33af4f064 100644 --- a/app/helpers/shared_search_helper.rb +++ b/app/helpers/shared_search_helper.rb @@ -2,22 +2,21 @@ module SharedSearchHelper def generate_work_url(model, request) - # needed because some attributes eg id is a symbol 7 others are string + # handle the various types of info we receive: if model.class == Hyrax::IiifAv::IiifFileSetPresenter - has_model = model.model_name.plural + base_route_name = model.model_name.plural id = model.id account_cname = request.server_name else - model = model.to_h.with_indifferent_access - - cname = model["account_cname_tesim"] - account_cname = Array.wrap(cname).first - - has_model = model["has_model_ssim"].first.underscore.pluralize - id = model["id"] + model_hash = model.to_h.with_indifferent_access + + base_route_name = model_hash["has_model_ssim"].first.constantize.model_name.plural + id = model_hash["id"] + account_cname = Array.wrap(model_hash["account_cname_tesim"]).first end + request_params = %i[protocol host port].map { |method| ["request_#{method}".to_sym, request.send(method)] }.to_h - url = get_url(id:, request: request_params, account_cname:, has_model:) + url = get_url(id:, request: request_params, account_cname:, base_route_name:) # pass search query params to work show page params[:q].present? ? "#{url}?q=#{params[:q]}" : url @@ -25,14 +24,14 @@ def generate_work_url(model, request) private - def get_url(id:, request:, account_cname:, has_model:) + def get_url(id:, request:, account_cname:, base_route_name:) new_url = "#{request[:request_protocol]}#{account_cname || request[:request_host]}" new_url += ":#{request[:request_port]}" if Rails.env.development? || Rails.env.test? - new_url += case has_model + new_url += case base_route_name when "collections" - "/#{has_model}/#{id}" + "/#{base_route_name}/#{id}" else - "/concern/#{has_model}/#{id}" + "/concern/#{base_route_name}/#{id}" end new_url end diff --git a/app/indexers/admin_set_resource_indexer.rb b/app/indexers/admin_set_resource_indexer.rb new file mode 100644 index 000000000..689159cff --- /dev/null +++ b/app/indexers/admin_set_resource_indexer.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +class AdminSetResourceIndexer < Hyrax::Indexers::AdministrativeSetIndexer +end \ No newline at end of file diff --git a/app/indexers/collection_resource_indexer.rb b/app/indexers/collection_resource_indexer.rb new file mode 100644 index 000000000..9cafa241c --- /dev/null +++ b/app/indexers/collection_resource_indexer.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +# Generated via +# `rails generate hyrax:collection_resource CollectionResource` +class CollectionResourceIndexer < Hyrax::Indexers::PcdmCollectionIndexer + include Hyrax::Indexer(:basic_metadata) + include Hyrax::Indexer(:collection_resource) + + def to_solr + super.tap do |index_document| + index_document["account_cname_tesim"] = Site.instance&.account&.cname + index_document['account_institution_name_ssim'] = Site.instance.institution_label + end + end +end diff --git a/app/models/hyrax/administrative_set_decorator.rb b/app/models/admin_set_resource.rb similarity index 50% rename from app/models/hyrax/administrative_set_decorator.rb rename to app/models/admin_set_resource.rb index 46e368386..dd74d8ec6 100644 --- a/app/models/hyrax/administrative_set_decorator.rb +++ b/app/models/admin_set_resource.rb @@ -1,8 +1,6 @@ # frozen_string_literal: true -# OVERRIDE Hyrax 5.0 to add AF methods to collection - -Hyrax::AdministrativeSet.class_eval do +class AdminSetResource < Hyrax::AdministrativeSet include Hyrax::ArResource include Hyrax::Permissions::Readable -end +end \ No newline at end of file diff --git a/app/models/collection_resource.rb b/app/models/collection_resource.rb new file mode 100644 index 000000000..1ab439e6e --- /dev/null +++ b/app/models/collection_resource.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +# Generated via +# `rails generate hyrax:collection_resource CollectionResource` +class CollectionResource < Hyrax::PcdmCollection + include Hyrax::Schema(:basic_metadata) + include Hyrax::Schema(:collection_resource) + include Hyrax::ArResource + # This module provides the #public?, #private?, #restricted? methods; consider + # contributing this back to Hyrax; but that decision requires further discussion + # on architecture. + # @see https://samvera.slack.com/archives/C0F9JQJDQ/p1705421588370699 Slack discussion thread. + include Hyrax::Permissions::Readable + prepend OrderAlready.for(:creator) +end diff --git a/app/models/hyrax/pcdm_collection_decorator.rb b/app/models/hyrax/pcdm_collection_decorator.rb deleted file mode 100644 index 00412b005..000000000 --- a/app/models/hyrax/pcdm_collection_decorator.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -# OVERRIDE Hyrax 5.0 to add basic metadata and AF methods to collection - -Hyrax::PcdmCollection.class_eval do - include Hyrax::Schema(:basic_metadata) - include Hyrax::ArResource - - # This module provides the #public?, #private?, #registered? methods; consider contributing this - # back to Hyrax; but that decision requires further discussion on architecture. - # @see https://samvera.slack.com/archives/C0F9JQJDQ/p1705421588370699 Slack discussion thread. - include Hyrax::Permissions::Readable - prepend OrderAlready.for(:creator) -end diff --git a/app/services/roles_service.rb b/app/services/roles_service.rb index 28424cc27..cfbce7a5c 100644 --- a/app/services/roles_service.rb +++ b/app/services/roles_service.rb @@ -233,9 +233,12 @@ def seed_qa_users! class GrantWorkflowRolesForAllAdminSetsJob < Hyrax::ApplicationJob def perform - Hyrax.query_service.find_all_of_model(model: Hyrax.config.admin_set_class).each do |admin_set| - permission_template = Hyrax::PermissionTemplate.find_or_create_by!(source_id: admin_set.id) - Hyrax::Workflow::PermissionGrantor.grant_default_workflow_roles!(permission_template:) + models = [AdminSet, Hyrax::AdministrativeSet, Hyrax.config.admin_set_class].uniq + models.each do |admin_set_model| + Hyrax.query_service.find_all_of_model(model: admin_set_model) do |admin_set| + Hyrax::Workflow::PermissionGrantor + .grant_default_workflow_roles!(permission_template: admin_set.permission_template) + end end end end @@ -243,35 +246,38 @@ def perform class CreateCollectionAccessesJob < Hyrax::ApplicationJob # rubocop:disable Metrics/MethodLength def perform - Hyrax.query_service.find_all_of_model(model: Hyrax.config.collection_class).each do |collection| - pt = Hyrax::PermissionTemplate.find_or_create_by!(source_id: collection.id) - original_access_grants_count = pt.access_grants.count - - pt.access_grants.find_or_create_by!( - access: Hyrax::PermissionTemplateAccess::MANAGE, - agent_type: Hyrax::PermissionTemplateAccess::GROUP, - agent_id: Ability.admin_group_name - ) - - pt.access_grants.find_or_create_by!( - access: Hyrax::PermissionTemplateAccess::MANAGE, - agent_type: Hyrax::PermissionTemplateAccess::GROUP, - agent_id: 'collection_manager' - ) - - pt.access_grants.find_or_create_by!( - access: Hyrax::PermissionTemplateAccess::VIEW, - agent_type: Hyrax::PermissionTemplateAccess::GROUP, - agent_id: 'collection_editor' - ) - - pt.access_grants.find_or_create_by!( - access: Hyrax::PermissionTemplateAccess::VIEW, - agent_type: Hyrax::PermissionTemplateAccess::GROUP, - agent_id: 'collection_reader' - ) - - pt.reset_access_controls_for(collection:) if pt.access_grants.count != original_access_grants_count + models = [Collection, Hyrax::PcdmCollection, Hyrax.config.collection_class].uniq + models.each do |collection_model| + Hyrax.query_service.find_all_of_model(model: collection_model) do |c| + pt = Hyrax::PermissionTemplate.find_or_create_by!(source_id: c.id) + original_access_grants_count = pt.access_grants.count + + pt.access_grants.find_or_create_by!( + access: Hyrax::PermissionTemplateAccess::MANAGE, + agent_type: Hyrax::PermissionTemplateAccess::GROUP, + agent_id: Ability.admin_group_name + ) + + pt.access_grants.find_or_create_by!( + access: Hyrax::PermissionTemplateAccess::MANAGE, + agent_type: Hyrax::PermissionTemplateAccess::GROUP, + agent_id: 'collection_manager' + ) + + pt.access_grants.find_or_create_by!( + access: Hyrax::PermissionTemplateAccess::VIEW, + agent_type: Hyrax::PermissionTemplateAccess::GROUP, + agent_id: 'collection_editor' + ) + + pt.access_grants.find_or_create_by!( + access: Hyrax::PermissionTemplateAccess::VIEW, + agent_type: Hyrax::PermissionTemplateAccess::GROUP, + agent_id: 'collection_reader' + ) + + pt.reset_access_controls_for(collection: c) if pt.access_grants.count != original_access_grants_count + end end end # rubocop:enable Metrics/MethodLength @@ -280,35 +286,38 @@ def perform class CreateAdminSetAccessesJob < Hyrax::ApplicationJob # rubocop:disable Metrics/MethodLength def perform - Hyrax.query_service.find_all_of_model(model: Hyrax.config.admin_set_class).each do |admin_set| - pt = Hyrax::PermissionTemplate.find_or_create_by!(source_id: admin_set.id) - original_access_grants_count = pt.access_grants.count - - pt.access_grants.find_or_create_by!( - access: Hyrax::PermissionTemplateAccess::MANAGE, - agent_type: Hyrax::PermissionTemplateAccess::GROUP, - agent_id: Ability.admin_group_name - ) - - pt.access_grants.find_or_create_by!( - access: Hyrax::PermissionTemplateAccess::DEPOSIT, - agent_type: Hyrax::PermissionTemplateAccess::GROUP, - agent_id: 'work_depositor' - ) - - pt.access_grants.find_or_create_by!( - access: Hyrax::PermissionTemplateAccess::DEPOSIT, - agent_type: Hyrax::PermissionTemplateAccess::GROUP, - agent_id: 'work_editor' - ) - - pt.access_grants.find_or_create_by!( - access: Hyrax::PermissionTemplateAccess::VIEW, - agent_type: Hyrax::PermissionTemplateAccess::GROUP, - agent_id: 'work_editor' - ) - - pt.reset_access_controls_for(collection: admin_set) if pt.access_grants.count != original_access_grants_count + models = [AdminSet, Hyrax::AdministrativeSet, Hyrax.config.admin_set_class].uniq + models.each do |admin_set_model| + Hyrax.query_service.find_all_of_model(model: admin_set_model) do |as| + pt = Hyrax::PermissionTemplate.find_or_create_by!(source_id: as.id) + original_access_grants_count = pt.access_grants.count + + pt.access_grants.find_or_create_by!( + access: Hyrax::PermissionTemplateAccess::MANAGE, + agent_type: Hyrax::PermissionTemplateAccess::GROUP, + agent_id: Ability.admin_group_name + ) + + pt.access_grants.find_or_create_by!( + access: Hyrax::PermissionTemplateAccess::DEPOSIT, + agent_type: Hyrax::PermissionTemplateAccess::GROUP, + agent_id: 'work_depositor' + ) + + pt.access_grants.find_or_create_by!( + access: Hyrax::PermissionTemplateAccess::DEPOSIT, + agent_type: Hyrax::PermissionTemplateAccess::GROUP, + agent_id: 'work_editor' + ) + + pt.access_grants.find_or_create_by!( + access: Hyrax::PermissionTemplateAccess::VIEW, + agent_type: Hyrax::PermissionTemplateAccess::GROUP, + agent_id: 'work_editor' + ) + + pt.reset_access_controls_for(collection: as) if pt.access_grants.count != original_access_grants_count + end end end # rubocop:enable Metrics/MethodLength diff --git a/app/views/hyrax/admin/users/index.html.erb b/app/views/hyrax/admin/users/index.html.erb index c3c7e44a0..97be3ec03 100644 --- a/app/views/hyrax/admin/users/index.html.erb +++ b/app/views/hyrax/admin/users/index.html.erb @@ -17,8 +17,8 @@
<%# user_invitation_path is provided by devise_invitable %> <%= simple_form_for :user, url: main_app.user_invitation_path, html: { class: 'form-inline d-inline-flex' } do |f| %> + <%= f.hint :email %>
- <%= f.hint :email %> <%= f.label :email, class: "control-label", required: false %> <%= f.input_field :email, class: "form-control", value: "" %> <%= f.select :role, diff --git a/config/initializers/hyrax.rb b/config/initializers/hyrax.rb index 6ffc8d91e..086e21a50 100644 --- a/config/initializers/hyrax.rb +++ b/config/initializers/hyrax.rb @@ -20,12 +20,14 @@ # Identify the model class name that will be used for Collections in your app # (i.e. ::Collection for ActiveFedora, Hyrax::PcdmCollection for Valkyrie) # config.collection_model = '::Collection' - config.collection_model = 'Hyrax::PcdmCollection' + # Injected via `rails g hyrax:collection_resource CollectionResource` + config.collection_model = 'CollectionResource' # Identify the model class name that will be used for Admin Sets in your app # (i.e. AdminSet for ActiveFedora, Hyrax::AdministrativeSet for Valkyrie) # config.admin_set_model = 'AdminSet' - config.admin_set_model = 'Hyrax::AdministrativeSet' + config.admin_set_model = 'AdminSetResource' + # The email address that messages submitted via the contact page are sent to # This is set by account settings # config.contact_email = 'changeme@example.com' diff --git a/config/initializers/wings.rb b/config/initializers/wings.rb index 303395039..c6851d52e 100644 --- a/config/initializers/wings.rb +++ b/config/initializers/wings.rb @@ -10,9 +10,9 @@ Wings::ModelRegistry.register(klass, klass) end Wings::ModelRegistry.register(Collection, Collection) - Wings::ModelRegistry.register(Hyrax::PcdmCollection, Collection) + Wings::ModelRegistry.register(CollectionResource, Collection) Wings::ModelRegistry.register(AdminSet, AdminSet) - Wings::ModelRegistry.register(Hyrax::AdministrativeSet, AdminSet) + Wings::ModelRegistry.register(AdminSetResource, AdminSet) Wings::ModelRegistry.register(FileSet, FileSet) Wings::ModelRegistry.register(Hyrax::FileSet, FileSet) @@ -64,11 +64,11 @@ end Rails.application.config.to_prepare do - Hyrax::AdministrativeSet.class_eval do + AdminSetResource.class_eval do attribute :internal_resource, Valkyrie::Types::Any.default("AdminSet"), internal: true end - Hyrax::PcdmCollection.class_eval do + CollectionResource.class_eval do attribute :internal_resource, Valkyrie::Types::Any.default("Collection"), internal: true end @@ -85,9 +85,9 @@ ].include?(klass_name) "#{klass_name}Resource".constantize elsif 'Collection' == klass_name - Hyrax::PcdmCollection + CollectionResource elsif 'AdminSet' == klass_name - Hyrax::AdministrativeSet + AdminSetResource # Without this mapping, we'll see cases of Postgres Valkyrie adapter attempting to write to # Fedora. Yeah! elsif 'Hydra::AccessControl' == klass_name diff --git a/config/metadata/collection_resource.yaml b/config/metadata/collection_resource.yaml new file mode 100644 index 000000000..9e9e232fc --- /dev/null +++ b/config/metadata/collection_resource.yaml @@ -0,0 +1,24 @@ +# Simple yaml config-driven schema which is used to define model attributes, +# index key names, and form properties. +# +# Attributes must have a type but all other configuration options are optional. +# Please note: If using Valkyrie's Fedora Metadata Adapter, predicates for attributes +# must be placed here. +# +# attributes: +# attribute_name: +# type: string +# multiple: false +# index_keys: +# - "attribute_name_sim" +# form: +# required: true +# primary: true +# multiple: false +# +# @see config/metadata/basic_metadata.yaml for an example configuration +# +# Generated via +# `rails generate hyrax:collection_resource CollectionResource` + +attributes: {} diff --git a/spec/forms/admin_set_resource_spec.rb b/spec/forms/admin_set_resource_spec.rb new file mode 100644 index 000000000..5f008426f --- /dev/null +++ b/spec/forms/admin_set_resource_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require 'rails_helper' +require 'valkyrie/specs/shared_specs' + +RSpec.describe AdminSetResourceForm do + let(:change_set) { described_class.new(resource) } + let(:resource) { AdminSetResource.new } + + it_behaves_like 'a Valkyrie::ChangeSet' +end \ No newline at end of file diff --git a/spec/forms/collection_resource_form_spec.rb b/spec/forms/collection_resource_form_spec.rb new file mode 100644 index 000000000..4e05d208b --- /dev/null +++ b/spec/forms/collection_resource_form_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +# Generated via +# `rails generate hyrax:collection_resource CollectionResource` +require 'rails_helper' +require 'valkyrie/specs/shared_specs' + +RSpec.describe CollectionResourceForm do + let(:change_set) { described_class.new(resource) } + let(:resource) { CollectionResource.new } + + it_behaves_like 'a Valkyrie::ChangeSet' +end diff --git a/spec/indexers/admin_set_resource_indexer_spec.rb b/spec/indexers/admin_set_resource_indexer_spec.rb new file mode 100644 index 000000000..0e49eaa8e --- /dev/null +++ b/spec/indexers/admin_set_resource_indexer_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require 'rails_helper' +require 'hyrax/specs/shared_specs/indexers' + +RSpec.describe AdminSetResourceIndexer do + let(:indexer_class) { described_class } + let(:resource) { AdminSetResource.new } + + it_behaves_like 'a Hyrax::Resource indexer' +end diff --git a/spec/indexers/collection_resource_indexer_spec.rb b/spec/indexers/collection_resource_indexer_spec.rb new file mode 100644 index 000000000..e2e219b67 --- /dev/null +++ b/spec/indexers/collection_resource_indexer_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +# Generated via +# `rails generate hyrax:collection_resource CollectionResource` +require 'rails_helper' +require 'hyrax/specs/shared_specs/indexers' + +RSpec.describe CollectionResourceIndexer do + let(:indexer_class) { described_class } + let(:resource) { CollectionResource.new } + + it_behaves_like 'a Hyrax::Resource indexer' +end diff --git a/spec/models/admin_set_resource_spec.rb b/spec/models/admin_set_resource_spec.rb new file mode 100644 index 000000000..88c08db00 --- /dev/null +++ b/spec/models/admin_set_resource_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe AdminSetResource do + subject(:admin_set) { described_class.new } + + it_behaves_like 'a Hyrax::AdministrativeSet' + + context 'with Hyrax::Permissions::Readable' do + it { is_expected.to respond_to :public? } + it { is_expected.to respond_to :private? } + it { is_expected.to respond_to :registered? } + end +end diff --git a/spec/models/hyrax/pcdm_collection_decorator_spec.rb b/spec/models/collection_resource_spec.rb similarity index 89% rename from spec/models/hyrax/pcdm_collection_decorator_spec.rb rename to spec/models/collection_resource_spec.rb index fd5e83ccc..64de53a85 100644 --- a/spec/models/hyrax/pcdm_collection_decorator_spec.rb +++ b/spec/models/collection_resource_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Hyrax::PcdmCollection do +RSpec.describe CollectionResource do subject(:collection) { described_class.new } it_behaves_like 'a Hyrax::PcdmCollection' diff --git a/spec/models/hyrax/administrative_set_spec.rb b/spec/models/hyrax/administrative_set_spec.rb deleted file mode 100644 index ebfcc293f..000000000 --- a/spec/models/hyrax/administrative_set_spec.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe Hyrax::AdministrativeSet do - describe 'factories' do - context ':hyku_admin_set' do - it 'successfully creates an admin set, admin group, and permission template' do - expect do - expect do - expect do - FactoryBot.valkyrie_create(:hyku_admin_set) - end.to change { Hyrax::PermissionTemplate.count }.by(1) - end.to change { Hyrax.query_service.count_all_of_model(model: Hyrax::AdministrativeSet) }.by(1) - end.to change { Hyrax::Group.where(name: ::Ability.admin_group_name).count }.by(1) - end - end - end -end