-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
256 additions
and
80 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module Hyrax | ||
module Workflow | ||
class ApprovedNotification < AbstractNotification | ||
private | ||
|
||
def subject | ||
'Deposit #{title} has been approved' | ||
end | ||
|
||
def message | ||
"#{title} (#{link_to work_id, document_path}) has been approved by #{user.user_key} #{comment}" | ||
end | ||
|
||
def users_to_notify | ||
super << user | ||
end | ||
end | ||
end | ||
end |
21 changes: 21 additions & 0 deletions
21
app/services/hyrax/workflow/pending_approval_notification.rb
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module Hyrax | ||
module Workflow | ||
class PendingApprovalNotification < AbstractNotification | ||
protected | ||
|
||
def subject | ||
"Deposit #{title} is awaiting approval" | ||
end | ||
|
||
def message | ||
"#{title} (#{link_to work_id, document_path}) was deposited by #{user.user_key} and is awaiting approval. #{comment}" | ||
end | ||
|
||
private | ||
|
||
def users_to_notify | ||
super << user | ||
end | ||
end | ||
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 |
---|---|---|
@@ -0,0 +1,102 @@ | ||
{ | ||
"workflows": [ | ||
{ | ||
"name": "emory_one_step_approval", | ||
"label": "One-step approval tailored for Emory", | ||
"description": "A single-step workflow for mediated deposit in which all deposits must be approved by an approver. Approver may also send deposits back to the depositor, comment on the work, and hide or unhide a work.", | ||
"allows_access_grant": false, | ||
"actions": [ | ||
{ | ||
"name": "deposit", | ||
"from_states": [], | ||
"transition_to": "pending_approval", | ||
"notifications": [ | ||
{ | ||
"notification_type": "email", | ||
"name": "Hyrax::Workflow::PendingApprovalNotification", | ||
"to": ["approving", "depositing"] | ||
} | ||
], | ||
"methods": [ | ||
"Hyrax::Workflow::DeactivateObject" | ||
] | ||
}, { | ||
"name": "request_changes", | ||
"from_states": [{"names": ["approved", "pending_approval"], "roles": ["approving"]}], | ||
"transition_to": "changes_required", | ||
"notifications": [ | ||
{ | ||
"notification_type": "email", | ||
"name": "Hyrax::Workflow::ChangesRequiredNotification", | ||
"to": ["approving"] | ||
} | ||
], | ||
"methods": [ | ||
"Hyrax::Workflow::DeactivateObject" | ||
] | ||
}, { | ||
"name": "approve", | ||
"from_states": [{"names": ["pending_approval"], "roles": ["approving"]}], | ||
"transition_to": "approved", | ||
"notifications": [ | ||
{ | ||
"notification_type": "email", | ||
"name": "Hyrax::Workflow::ApprovedNotification", | ||
"to": ["approving", "depositing"] | ||
} | ||
], | ||
"methods": [ | ||
"Hyrax::Workflow::ActivateObject" | ||
] | ||
}, { | ||
"name": "request_review", | ||
"from_states": [{"names": ["changes_required"], "roles": ["depositing"]}], | ||
"transition_to": "pending_approval", | ||
"notifications": [ | ||
{ | ||
"notification_type": "email", | ||
"name": "Hyrax::Workflow::PendingReviewNotification", | ||
"to": ["approving"] | ||
} | ||
] | ||
}, { | ||
"name": "comment_only", | ||
"from_states": [ | ||
{ "names": ["pending_approval", "approved"], "roles": ["approving"] }, | ||
{ "names": ["changes_required"], "roles": ["depositing"] } | ||
] | ||
}, { | ||
"name": "hide", | ||
"from_states": [ | ||
{ "names": ["pending_review", "pending_approval", "approved", "changes_required"], "roles": ["reviewing", "approving"] } | ||
], | ||
"notifications": [ | ||
{ | ||
"notification_type": "email", | ||
"name": "Hyrax::Workflow::HiddenNotification", | ||
"to": ["approving"] | ||
} | ||
], | ||
"methods": [ | ||
"Hyrax::Workflow::HideObject" | ||
] | ||
}, { | ||
"name": "unhide", | ||
"from_states": [ | ||
{ "names": ["pending_review", "pending_approval", "approved", "changes_required"], "roles": ["reviewing", "approving"] } | ||
], | ||
"notifications": [ | ||
{ | ||
"notification_type": "email", | ||
"name": "Hyrax::Workflow::UnhiddenNotification", | ||
"to": ["approving"] | ||
} | ||
], | ||
"methods": [ | ||
"Hyrax::Workflow::UnhideObject" | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# Generated via | ||
# `rails generate hyrax:work Etd` | ||
require 'rails_helper' | ||
require 'active_fedora/cleaner' | ||
require 'workflow_setup' | ||
include Warden::Test::Helpers | ||
|
||
RSpec.feature 'Create a Rollins ETD' do | ||
let(:user) { create :user } | ||
let(:w) { WorkflowSetup.new("#{fixture_path}/config/emory/superusers.yml", "#{fixture_path}/config/emory/", "#{::Rails.root}/config/emory/schools.yml", "/dev/null") } | ||
let(:superuser) { w.superusers.first } | ||
context 'a logged in user' do | ||
before do | ||
ActiveFedora::Cleaner.clean! | ||
w.setup | ||
login_as user | ||
end | ||
|
||
scenario "Miranda submits a thesis and an approver approves it" do | ||
visit("/concern/etds/new") | ||
expect(page).to have_css('input#etd_title.required') | ||
expect(page).not_to have_css('input#etd_title.multi_value') | ||
expect(page).to have_css('input#etd_creator.required') | ||
expect(page).not_to have_css('input#etd_creator.multi_value') | ||
title = "Global Public Health #{rand}" | ||
fill_in 'Title', with: title | ||
fill_in 'Student Name', with: 'Park, Miranda' | ||
fill_in "Department", with: "Global Health" | ||
fill_in "School", with: "Rollins School of Public Health" | ||
select('CDC', from: 'Partnering agency') | ||
choose('open') | ||
check('agreement') | ||
click_on('My PDF') | ||
page.attach_file('files[]', "#{fixture_path}/miranda/miranda_thesis.pdf") | ||
# TODO: Miranda fixture folder has supplementary files. Add these when we're ready | ||
click_on("Review") | ||
select("Rollins School of Public Health", from: "Add as member of administrative set") | ||
click_on('Save') | ||
expect(page).to have_content title | ||
expect(page).to have_content 'Pending approval' | ||
|
||
# Check the ETD was assigned the right workflow | ||
etd = Etd.where(title: [title]).first | ||
expect(etd.active_workflow.name).to eq "emory_one_step_approval" | ||
expect(etd.to_sipity_entity.reload.workflow_state_name).to eq "pending_approval" | ||
|
||
# Check workflow permissions for depositing user | ||
available_workflow_actions = Hyrax::Workflow::PermissionQuery.scope_permitted_workflow_actions_available_for_current_state(user: user, entity: etd.to_sipity_entity).pluck(:name) | ||
expect(available_workflow_actions.include?("mark_as_reviewed")).to eq false | ||
expect(available_workflow_actions.include?("approve")).to eq false | ||
expect(available_workflow_actions.include?("request_changes")).to eq false | ||
expect(available_workflow_actions.include?("comment_only")).to eq false | ||
expect(available_workflow_actions.include?("hide")).to eq false | ||
expect(available_workflow_actions.include?("unhide")).to eq false | ||
|
||
# Check notifications for depositing user | ||
visit("/notifications?locale=en") | ||
expect(page).to have_content "#{title} (#{etd.id}) was deposited by #{user.email} and is awaiting approval." | ||
|
||
# Check notifications for approving user | ||
logout | ||
approving_user = User.where(email: "rollinsadmin@emory.edu").first | ||
login_as approving_user | ||
visit("/notifications?locale=en") | ||
expect(page).to have_content "#{title} (#{etd.id}) was deposited by #{user.email} and is awaiting approval." | ||
|
||
# Check workflow permissions for approving user | ||
available_workflow_actions = Hyrax::Workflow::PermissionQuery.scope_permitted_workflow_actions_available_for_current_state(user: approving_user, entity: etd.to_sipity_entity).pluck(:name) | ||
expect(available_workflow_actions.include?("mark_as_reviewed")).to eq false # this workflow step should only exist for Laney | ||
expect(available_workflow_actions.include?("approve")).to eq true | ||
expect(available_workflow_actions.include?("request_changes")).to eq true | ||
expect(available_workflow_actions.include?("comment_only")).to eq true | ||
expect(available_workflow_actions.include?("hide")).to eq true | ||
expect(available_workflow_actions.include?("unhide")).to eq true | ||
|
||
# Last superuser should have all workflow options available. (First superuser gets these by virtue of owning the admin sets.) | ||
expect(w.superusers.count).to be > 1 # This test is meaningless if there is only one superuser | ||
available_workflow_actions = Hyrax::Workflow::PermissionQuery.scope_permitted_workflow_actions_available_for_current_state(user: w.superusers.last, entity: etd.to_sipity_entity).pluck(:name) | ||
expect(available_workflow_actions.include?("mark_as_reviewed")).to eq false # this workflow step should only exist for Laney | ||
expect(available_workflow_actions.include?("approve")).to eq true | ||
expect(available_workflow_actions.include?("request_changes")).to eq true | ||
expect(available_workflow_actions.include?("comment_only")).to eq true | ||
expect(available_workflow_actions.include?("hide")).to eq true | ||
expect(available_workflow_actions.include?("unhide")).to eq true | ||
|
||
# The approving user marks the etd as approved | ||
subject = Hyrax::WorkflowActionInfo.new(etd, approving_user) | ||
sipity_workflow_action = PowerConverter.convert_to_sipity_action("approve", scope: subject.entity.workflow) { nil } | ||
Hyrax::Workflow::WorkflowActionService.run(subject: subject, action: sipity_workflow_action, comment: nil) | ||
expect(etd.to_sipity_entity.reload.workflow_state_name).to eq "approved" | ||
|
||
# Check notifications for approving user | ||
visit("/notifications?locale=en") | ||
expect(page).to have_content "#{title} (#{etd.id}) has been approved by" | ||
|
||
# Check notifications for depositor again | ||
logout | ||
login_as user | ||
visit("/notifications?locale=en") | ||
expect(page).to have_content "#{title} (#{etd.id}) has been approved by" | ||
end | ||
end | ||
end |
2 changes: 2 additions & 0 deletions
2
spec/fixtures/config/emory/rollins_school_of_public_health.yml
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
workflow: | ||
- emory_one_step_approval | ||
approving: | ||
- rollinsadmin@emory.edu | ||
- rollinsadmin2@emory.edu |
Binary file not shown.
Binary file not shown.
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