-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add notion of 'depositor review' to one step mediated deposit workflow
- Loading branch information
Josh Gum
committed
Dec 1, 2016
1 parent
694ed19
commit 4f677f5
Showing
3 changed files
with
84 additions
and
3 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
app/services/sufia/workflow/changes_required_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,22 @@ | ||
module Sufia | ||
module Workflow | ||
class ChangesRequiredNotification < AbstractNotification | ||
protected | ||
|
||
def subject | ||
'Your deposit requires changes' | ||
end | ||
|
||
def message | ||
"#{title} (#{work_id}) requires additional changes before approval.\n\n '#{comment}'" | ||
end | ||
|
||
private | ||
|
||
def users_to_notify | ||
user_key = ActiveFedora::Base.find(work_id).depositor | ||
super << ::User.find_by(email: user_key) | ||
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
32 changes: 32 additions & 0 deletions
32
spec/services/sufia/workflow/changes_required_notification_spec.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,32 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe Sufia::Workflow::ChangesRequiredNotification do | ||
let(:approver) { create(:user) } | ||
let(:depositor) { create(:user) } | ||
let(:to_user) { create(:user) } | ||
let(:cc_user) { create(:user) } | ||
let(:work) { create(:generic_work, user: depositor) } | ||
let(:entity) { create(:sipity_entity, proxy_for_global_id: work.to_global_id.to_s) } | ||
let(:comment) { double("comment", comment: 'A pleasant read') } | ||
let(:recipients) { { 'to' => [to_user], 'cc' => [cc_user] } } | ||
|
||
describe ".send_notification" do | ||
it 'sends a message to all users' do | ||
expect(approver).to receive(:send_message).once.and_call_original | ||
|
||
expect { described_class.send_notification(entity: entity, user: approver, comment: comment, recipients: recipients) } | ||
.to change { depositor.mailbox.inbox.count }.by(1) | ||
.and change { to_user.mailbox.inbox.count }.by(1) | ||
.and change { cc_user.mailbox.inbox.count }.by(1) | ||
end | ||
context 'without carbon-copied users' do | ||
let(:recipients) { { 'to' => [to_user] } } | ||
it 'sends a message to the to user(s)' do | ||
expect(approver).to receive(:send_message).once.and_call_original | ||
expect { described_class.send_notification(entity: entity, user: approver, comment: comment, recipients: recipients) } | ||
.to change { depositor.mailbox.inbox.count }.by(1) | ||
.and change { to_user.mailbox.inbox.count }.by(1) | ||
end | ||
end | ||
end | ||
end |