-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1046 from UNC-Libraries/hyc-1780-groups
HYC-1780 - Assign group roles to sage and proquest
- Loading branch information
Showing
5 changed files
with
85 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,8 +136,22 @@ | |
# most processing functionality is tested in process_all_packages | ||
# this test is to make sure only selected packages are processed | ||
describe '#process_packages' do | ||
let(:manager) do | ||
FactoryBot.create(:user, email: '[email protected]', guest: false, uid: 'manager') | ||
end | ||
let(:manager_agent) { Sipity::Agent.where(proxy_for_id: 'dissertation_manager', proxy_for_type: 'Hyrax::Group').first_or_create } | ||
|
||
before do | ||
Dissertation.delete_all | ||
|
||
Hyrax::PermissionTemplateAccess.create(permission_template: permission_template, | ||
agent_type: 'group', | ||
agent_id: 'dissertation_manager', | ||
access: 'manage') | ||
Hyrax::Workflow::PermissionGenerator.call(roles: 'managing', workflow: workflow, agents: manager_agent) | ||
manager_role = Role.where(name: 'dissertation_manager').first_or_create | ||
manager_role.users << manager | ||
manager_role.save | ||
end | ||
|
||
let(:filepath_array) { ['spec/fixtures/proquest/proquest-attach0.zip'] } | ||
|
@@ -152,6 +166,22 @@ | |
expect(package1['status']).to eq 'Complete' | ||
expect(package1['status_timestamp']).to_not be_nil | ||
expect(package1['error']).to be_nil | ||
|
||
# Dissertation and both of its files should have the manager role assigned to it | ||
dissertation = Dissertation.first | ||
expect_to_have_manager_permission(dissertation) | ||
|
||
diss_file_sets = dissertation.file_sets | ||
expect(diss_file_sets.length).to eq 2 | ||
expect_to_have_manager_permission(diss_file_sets[0]) | ||
expect_to_have_manager_permission(diss_file_sets[1]) | ||
expect(diss_file_sets[1].visibility).to eq Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE | ||
end | ||
|
||
def expect_to_have_manager_permission(item) | ||
perm = item.permissions.first | ||
expect(perm.agent.first.id).to eq 'http://projecthydra.org/ns/auth/group#dissertation_manager' | ||
expect(perm.mode.first.id).to eq 'http://www.w3.org/ns/auth/acl#Write' | ||
end | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,8 +88,26 @@ | |
let(:updated_creator) { 'Nakayama, Don K.' } | ||
|
||
context 'revision with no existing work' do | ||
let(:manager) do | ||
FactoryBot.create(:user, email: '[email protected]', guest: false, uid: 'manager') | ||
end | ||
let(:manager_agent) { Sipity::Agent.where(proxy_for_id: 'oa_manager', proxy_for_type: 'Hyrax::Group').first_or_create } | ||
|
||
let(:package_name) { 'ASU_2022_88_10_10.1177_00031348221074228.r2022-12-22.zip' } | ||
|
||
before do | ||
Article.delete_all | ||
|
||
Hyrax::PermissionTemplateAccess.create(permission_template: permission_template, | ||
agent_type: 'group', | ||
agent_id: 'oa_manager', | ||
access: 'manage') | ||
Hyrax::Workflow::PermissionGenerator.call(roles: 'managing', workflow: workflow, agents: manager_agent) | ||
manager_role = Role.where(name: 'oa_manager').first_or_create | ||
manager_role.users << manager | ||
manager_role.save | ||
end | ||
|
||
it 'creates the work as if it were new' do | ||
work_id = nil | ||
expect { work_id = service.process_package("spec/fixtures/sage/revisions/both_changed/#{package_name}") } | ||
|
@@ -101,6 +119,26 @@ | |
expect(status['status']).to eq 'In Progress' | ||
expect(status['error'][0]['message']).to eq "Package #{package_name} indicates that it is a revision, but no existing work with DOI https://doi.org/10.1177/00031348221074228 was found. Creating a new work instead." | ||
expect(status['error'][0]['trace']).to be_nil | ||
|
||
article = Article.first | ||
expect_to_have_manager_permission(article) | ||
expect_to_have_public_permission(article) | ||
|
||
article_file_sets = article.file_sets | ||
expect(article_file_sets.length).to eq 2 | ||
expect_to_have_manager_permission(article_file_sets[0]) | ||
expect_to_have_public_permission(article_file_sets[0]) | ||
expect_to_have_manager_permission(article_file_sets[1]) | ||
end | ||
|
||
def expect_to_have_manager_permission(item) | ||
manager_perm = item.permissions.to_a.find { |perm| perm.agent.first.id == 'http://projecthydra.org/ns/auth/group#oa_manager' } | ||
expect(manager_perm.mode.first.id).to eq 'http://www.w3.org/ns/auth/acl#Write' | ||
end | ||
|
||
def expect_to_have_public_permission(item) | ||
pub_perm = item.permissions.to_a.find { |perm| perm.agent.first.id == 'http://projecthydra.org/ns/auth/group#public' } | ||
expect(pub_perm.mode.first.id).to eq 'http://www.w3.org/ns/auth/acl#Read' | ||
end | ||
end | ||
|
||
|