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

Valkyrize inherit_permissions_job #4227

Merged
merged 1 commit into from
Jan 31, 2020
Merged

Valkyrize inherit_permissions_job #4227

merged 1 commit into from
Jan 31, 2020

Conversation

bkeese
Copy link
Contributor

@bkeese bkeese commented Jan 28, 2020

Fixes #4200

Allows inherit_permissions_job to receive either an AF object or a Valkyrie resource as the Work

@samvera/hyrax-code-reviewers

@bkeese bkeese force-pushed the inherit_permissions_job branch 5 times, most recently from 183ae0f to d91927c Compare January 29, 2020 16:23
app/jobs/inherit_permissions_job.rb Outdated Show resolved Hide resolved
context "when read groups change" do
let(:name) { 'my_read_group' }
let(:type) { 'group' }
let(:access) { 'read' }

it 'copies permissions to its contained files' do
# files have the depositor as the edit user to begin with
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment does not appear to match described line below.

let(:access) { 'read' }

it 'copies permissions to its contained files' do
# files have the depositor as the edit user to begin with
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment does not appear to match described line below.

expect(file.read_groups).to match_array ["my_read_group"]
expect(file.edit_users).to match_array [user.to_s]
# files have both edit users from parent resource
Hyrax.query_service.custom_queries.find_child_filesets(resource: resource).each do |file|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In reading this spec, it would be possible that we have an empty array, which would mean the spec is not testing anything.

It may be helpful to capture the Hyrax.query_service.custom_queries.find_child_filesets(resource: resource) as a variable and say that you expect it to have a specific count/size.


described_class.perform_now(work)
described_class.perform_now(work, use_valkyrie: false)
work.reload.file_sets.each do |file|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In reading this spec, it would be possible that we have an empty array, which would mean the spec is not testing anything.

It may be helpful to capture the Hyrax.query_service.custom_queries.find_child_filesets(resource: resource) as a variable and say that you expect it to have a specific count/size.

expect(file.read_users).to match_array ["abc@123.com"]
expect(file.edit_users).to match_array [user.to_s]
described_class.perform_now(work, use_valkyrie: false)
work.reload.file_sets.each do |file|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In reading this spec, it would be possible that we have an empty array, which would mean the spec is not testing anything.

It may be helpful to capture the Hyrax.query_service.custom_queries.find_child_filesets(resource: resource) as a variable and say that you expect it to have a specific count/size.

described_class.perform_now(resource, use_valkyrie: true)

# files have single edit user from parent resource
Hyrax.query_service.custom_queries.find_child_filesets(resource: resource).each do |file|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In reading this spec, it would be possible that we have an empty array, which would mean the spec is not testing anything.

It may be helpful to capture the Hyrax.query_service.custom_queries.find_child_filesets(resource: resource) as a variable and say that you expect it to have a specific count/size.

described_class.perform_now(resource, use_valkyrie: true)

# files have the extra user as the read user
Hyrax.query_service.custom_queries.find_child_filesets(resource: resource).each do |file|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In reading this spec, it would be possible that we have an empty array, which would mean the spec is not testing anything.

It may be helpful to capture the Hyrax.query_service.custom_queries.find_child_filesets(resource: resource) as a variable and say that you expect it to have a specific count/size.

expect(resource.read_groups).to match_array ["my_read_group"]

described_class.perform_now(resource, use_valkyrie: true)
Hyrax.query_service.custom_queries.find_child_filesets(resource: resource).each do |file|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In reading this spec, it would be possible that we have an empty array, which would mean the spec is not testing anything.

It may be helpful to capture the Hyrax.query_service.custom_queries.find_child_filesets(resource: resource) as a variable and say that you expect it to have a specific count/size.

it 'copies permissions to its contained files' do
resource.permission_manager.acl.grant(:edit).to(group).save

# files have the depositor as the edit user to begin with
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment does not appear to match described line below.

expect(file.edit_groups).to match_array ["my_edit_group"]
expect(file.edit_users).to match_array [user.to_s]
described_class.perform_now(resource, use_valkyrie: true)
Hyrax.query_service.custom_queries.find_child_filesets(resource: resource).each do |file|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In reading this spec, it would be possible that we have an empty array, which would mean the spec is not testing anything.

It may be helpful to capture the Hyrax.query_service.custom_queries.find_child_filesets(resource: resource) as a variable and say that you expect it to have a specific count/size.

@jeremyf
Copy link
Contributor

jeremyf commented Jan 30, 2020

I have a lot of "copy/paste" comments, but I also am very thankful for your contribution and PR. Good stuff to move us ever towards Valkyrie.

@bkeese
Copy link
Contributor Author

bkeese commented Jan 30, 2020

Thank you @jeremyf. Good points. Fixed. Well, not quite fixed. I missed the ones in the AF part.

@bkeese
Copy link
Contributor Author

bkeese commented Jan 30, 2020

OK. Now they're all fixed.

jeremyf
jeremyf previously approved these changes Jan 30, 2020
@jeremyf
Copy link
Contributor

jeremyf commented Jan 30, 2020

Woot! Now…why is CircleCI failing.

@jeremyf jeremyf merged commit 6fc0b59 into master Jan 31, 2020
@jeremyf jeremyf deleted the inherit_permissions_job branch January 31, 2020 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow InheritPermissionsJob to receive either an ActiveFedora object or a Valkyrie resource
2 participants