-
Notifications
You must be signed in to change notification settings - Fork 2
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
8 changed files
with
95 additions
and
3 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
class ApplicationMailer < ActionMailer::Base | ||
default from: 'from@example.com' | ||
default from: 'no-reply-preassembly@.stanford.edu' | ||
layout 'mailer' | ||
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,10 @@ | ||
class JobMailer < ApplicationMailer | ||
default from: 'no-reply-preassembly-job@stanford.edu' | ||
|
||
def completion_email | ||
@job = params[:job_run] | ||
@user = @job.bundle_context.user | ||
mail(to: @user.email, subject: 'Your pre-assembly job has completed') | ||
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
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 @@ | ||
<%=@user.sunet_id%>, your <%=@job.job_type%> job #<%=@job.id%> completed. View the job details here: "=url_for(@job) will go here". |
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,37 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe JobMailer, type: :mailer do | ||
let(:user) do | ||
User.new(sunet_id: "Jdoe") | ||
end | ||
|
||
let(:bc) do | ||
BundleContext.new(id: 1, | ||
project_name: "SmokeTest", | ||
content_structure: 1, | ||
bundle_dir: "spec/test_data/images_jp2_tif", | ||
staging_style_symlink: false, | ||
content_metadata_creation: 1, | ||
user: user) | ||
end | ||
|
||
let(:discovery_report_run) do | ||
JobRun.new(id: 1, | ||
output_location: "/path/to/report", | ||
bundle_context: bc, | ||
job_type: "discovery_report") | ||
end | ||
|
||
let(:job_notification) { JobMailer.with(job_run: discovery_report_run).completion_email } | ||
|
||
it 'renders the headers' do | ||
expect(job_notification.subject).to eq("Your pre-assembly job has completed") | ||
expect(job_notification.to).to eq(["Jdoe@stanford.edu"]) | ||
expect(job_notification.from).to eq(["no-reply-preassembly-job@stanford.edu"]) | ||
end | ||
|
||
it 'renders the body' do | ||
expect(job_notification.body.encoded).to include("Jdoe, your discovery_report job #1 completed") | ||
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
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