Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Process GrantEditJob with either an AF object or a Valkyrie resource based on use_valkyrie parameter #4104

Closed
elrayle opened this issue Oct 21, 2019 · 1 comment
Assignees
Labels

Comments

@elrayle
Copy link
Contributor

elrayle commented Oct 21, 2019

Descriptive summary

Add use_valkyrie parameter to GrantEditJob #perform method. When true, use Valkyrie to get the file set object and set permissions on the valkyrie resource. Otherwise, continue to process the ActiveFedora fileset.

Rationale

Allow jobs to execute correctly with existing AF implementation or the wings Valkyrie implementation.

Expected behavior

GrantEditJob #perform method receives parameters file_set_id, user_key, use_valkyrie: true | false, finding a valkyrie resource when use_valkyrie is true or an AF object if use_valkyrie is false, and in both cases correctly grants edit to the user for the fileset. Parameter use_valkyrie defaults to : Hyrax.config.use_valkyrie?

To find a fileset by id for a resource, use...

id = Valkyrie::ID.new(file_set_id)
file_set_resource = Hyrax.query_service.find_by(id: file_set_id)

The process for setting the edit access is the same for both types of objects.

To save a fileset resource, use...

Hyrax.persister.save(resource: file_set_resource)

Actual behavior

GrantEditJob #perform method raises an exception (e.g. Unknown Argument) when use_valkyrie parameter is passed in.

Approach for Conversion

See Pattern for Jobs Receiving Parameter that may be an AF Object or a Valkyrie Resource

Steps to reproduce the behavior

  1. Need to add tests that validate that the same tests pass whether a Valkyrie::Resource or an AF object is passed.

See example of processing both objects in... file_set_actor_spec.rb

For testing this job, you can use something like...

RSpec.describe GrantEditJob do
  [true, false].each do |use_valkyrie|
    context "when use_valkyrie is #{use_valkyrie}" do
      ...
          described_class.perform_now(file_set.id, depositor.user_key, use_valkyrie: use_valkyrie)

Related work

@elrayle
Copy link
Contributor Author

elrayle commented Oct 25, 2019

Fixed by PR #4123

@elrayle elrayle closed this as completed Oct 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants