From 2dac8fcddf1bce5b78f1379188d40668c73dda61 Mon Sep 17 00:00:00 2001 From: Brad Watson Date: Wed, 10 Apr 2024 14:02:21 -0500 Subject: [PATCH 1/2] Points Hyrax::EditPermissionsService.build_service_object_from to Hyrax configuration variable. For L#44, the `if` test's subject is hard-coded and unaware of any customized form class that the Hyrax Engine's implementers could create and set inside the Engine's configuration. This swaps to the configuration variable that defaults to the same hard-coded class (`Hyrax::Forms::FileSetForm`). --- app/services/hyrax/edit_permissions_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/hyrax/edit_permissions_service.rb b/app/services/hyrax/edit_permissions_service.rb index be254a7083..53251555b7 100644 --- a/app/services/hyrax/edit_permissions_service.rb +++ b/app/services/hyrax/edit_permissions_service.rb @@ -41,7 +41,7 @@ def self.build_service_object_from(form:, ability:) # (+Hyrax::Forms::FileSetForm+), +:in_works_ids+ is prepopulated onto # the form object itself. For +Hyrax::Forms::FileSetEditForm+, the # +:in_works+ method is present on the wrapped +:model+. - if form.object.is_a?(Hyrax::Forms::FileSetForm) + if form.object.is_a?(Hyrax.config.file_set_form) object_id = form.object.in_works_ids.first new(object: Hyrax.query_service.find_by(id: object_id), ability: ability) else From 196fdcf7581147930f209ff16182e74f6b3639a7 Mon Sep 17 00:00:00 2001 From: Brad Watson Date: Wed, 10 Apr 2024 14:10:43 -0500 Subject: [PATCH 2/2] appeases rubocop --- app/services/hyrax/edit_permissions_service.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/services/hyrax/edit_permissions_service.rb b/app/services/hyrax/edit_permissions_service.rb index 53251555b7..97f219824c 100644 --- a/app/services/hyrax/edit_permissions_service.rb +++ b/app/services/hyrax/edit_permissions_service.rb @@ -32,7 +32,7 @@ class EditPermissionsService # * form_object.object.model = FileSet # * use work the file_set is in # No other object types are supported by this view. - def self.build_service_object_from(form:, ability:) + def self.build_service_object_from(form:, ability:) # rubocop:disable Metrics/AbcSize if form.object.respond_to?(:model) && form.object.model.work? # The provided form object is a work form. new(object: form.object, ability: ability) @@ -51,7 +51,7 @@ def self.build_service_object_from(form:, ability:) # The provided form object is a FileSet. new(object: form.object.in_works.first, ability: ability) end - end + end # rubocop:enable Metrics/AbcSize attr_reader :depositor, :unauthorized_collection_managers