Skip to content

Commit

Permalink
Adding project_name to subject line
Browse files Browse the repository at this point in the history
  • Loading branch information
atz committed Sep 27, 2018
1 parent ad3b0bf commit ca21977
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/mailers/job_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ class JobMailer < ApplicationMailer
def completion_email
@job_run = params[:job_run]
@user = @job_run.bundle_context.user
mail(to: @user.email, subject: "Your #{@job_run.job_type.humanize} job completed")
mail(to: @user.email, subject: @job_run.mail_subject)
end
end
5 changes: 5 additions & 0 deletions app/models/job_run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ def enqueue!
"#{job_type.camelize}Job".constantize.perform_later(self)
end

# @return [String] Subject line for notification email
def mail_subject
"[#{bundle_context.project_name}] Your #{job_type.humanize} job completed"
end

def send_notification
return unless output_location
JobMailer.with(job_run: self).completion_email.deliver_later
Expand Down
4 changes: 2 additions & 2 deletions spec/mailers/job_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
let(:job_notification) { described_class.with(job_run: job_run).completion_email }

it 'renders the headers' do
expect(job_notification.subject).to eq("Your Discovery report job completed")
expect(job_notification.subject).to eq("[Test_Project] Your Discovery report job completed")
expect(job_notification.to).to eq([job_run.bundle_context.user.email])
expect(job_notification.from).to eq(["no-reply-preassembly-job@stanford.edu"])
end
Expand All @@ -12,7 +12,7 @@
before { job_run.job_type = 1 }

it 'adapts depending on job_type' do
expect(job_notification.subject).to eq("Your Preassembly job completed")
expect(job_notification.subject).to eq("[Test_Project] Your Preassembly job completed")
end
end

Expand Down

0 comments on commit ca21977

Please sign in to comment.