Skip to content

Commit cbe3187

Browse files
committed
Combining achievement mailer to single course email and updating trigger
1 parent 6566ec7 commit cbe3187

File tree

8 files changed

+13
-69
lines changed

8 files changed

+13
-69
lines changed

app/jobs/cs_accelerator/check_next_steps_job.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@ def perform(achievement_id)
1010
return unless enrolment
1111
return if enrolment.current_state == "complete"
1212

13-
case achievement.activity.category
14-
when "online"
15-
AchievementMailer.with(user_id: user.id).completed_online_course.deliver_now
16-
when "face-to-face"
17-
AchievementMailer.with(user_id: user.id).completed_face_to_face_course.deliver_now
18-
end
13+
AchievementMailer.with(user_id: user.id).completed_course.deliver_now
1914
end
2015
end
2116
end

app/mailers/achievement_mailer.rb

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,10 @@ def complete
77
mail(to: @user, subject: @subject)
88
end
99

10-
def completed_face_to_face_course
10+
def completed_course
1111
@user = User.find(params[:user_id])
1212
@subject = "Take the next step on your subject knowledge certificate"
1313

1414
mail(to: @user, subject: @subject)
1515
end
16-
17-
def completed_online_course
18-
@user = User.find(params[:user_id])
19-
@subject = "Keep going with your subject knowledge certificate"
20-
21-
mail(to: @user, subject: @subject)
22-
end
2316
end

app/views/achievement_mailer/completed_online_course.html.erb renamed to app/views/achievement_mailer/completed_course.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<p class='govuk-body'>Thanks for engaging with the KS3 and GCSE Computer Science subject knowledge certificate. You're making great progress towards achieving your subject knowledge certificate.</p>
55
<p class='govuk-body'>Once you have completed your next face to face or remote course, you will have reached ten hours of CPD and become <b>eligible to take the test and achieve your qualification.</b></p>
66
<h3 class="govuk-heading-s">Next steps</h3>
7-
<p class='govuk-body'>Choose from any of our face to face or remote Computer Science Accelerator courses.</p>
7+
<p class='govuk-body'>Choose from any of our computer science subject knowledge courses.</p>
88
<%= link_to 'Browse all courses', courses_url(certificate: 'subject-knowledge', emailTrigger: 'CSA4'), class: 'govuk-button button' %>
99
<p class='govuk-body'>To check your progress or access further support, explore your <%= link_to 'personalised dashboard', cs_accelerator_certificate_url, class: 'ncce-link' %> which shows you the learning pathway and courses we recommend you take.</p>
1010
</div>

app/views/achievement_mailer/completed_face_to_face_course.text.erb renamed to app/views/achievement_mailer/completed_course.text.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Thanks for engaging with the KS3 and GCSE Computer Science subject knowledge cer
44

55
Next steps
66

7-
Choose from any of our Computer Science Accelerator courses.
7+
Choose from any of our computer science subject knowledge courses.
88

99
Browse all courses (<%= courses_url(certificate: 'subject-knowledge', emailTrigger: 'CSA4') %>)
1010

app/views/achievement_mailer/completed_face_to_face_course.html.erb

Lines changed: 0 additions & 11 deletions
This file was deleted.

app/views/achievement_mailer/completed_online_course.text.erb

Lines changed: 0 additions & 11 deletions
This file was deleted.

previews/mailers/achievement_mailer_preview.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ def complete__disabled
33
AchievementMailer.with(user_id: User.first.id, activity_id: Activity.first.id, preview: true).complete
44
end
55

6-
def completed_face_to_face_course
7-
AchievementMailer.with(user_id: User.first.id, preview: true).completed_face_to_face_course
8-
end
9-
10-
def completed_online_course
11-
AchievementMailer.with(user_id: User.first.id, preview: true).completed_online_course
6+
def completed_course
7+
AchievementMailer.with(user_id: User.first.id, preview: true).completed_course
128
end
139
end

spec/mailers/achievement_mailer_spec.rb

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44
let(:user) { create(:user) }
55
let(:activity) { create(:activity) }
66
let(:mail) { described_class.with(user_id: user.id, activity_id: activity.id).complete }
7-
let(:face_to_face_mail) { described_class.with(user_id: user.id).completed_face_to_face_course }
8-
let(:online_mail) { described_class.with(user_id: user.id).completed_online_course }
7+
let(:course_mail) { described_class.with(user_id: user.id).completed_course }
98
let(:subject) { "Congratulations on completing an activity" }
10-
let(:face_to_face_subject) { "Take the next step on your subject knowledge certificate" }
11-
let(:online_subject) { "Keep going with your subject knowledge certificate" }
9+
let(:course_subject) { "Take the next step on your subject knowledge certificate" }
1210

1311
describe "email" do
1412
it "renders the headers" do
@@ -30,35 +28,19 @@
3028
end
3129
end
3230

33-
describe "completed face to face course email" do
34-
it "renders the headers" do
35-
expect(face_to_face_mail.subject).to include(face_to_face_subject)
36-
expect(face_to_face_mail.to).to eq([user.email])
37-
expect(face_to_face_mail.from).to eq(["noreply@teachcomputing.org"])
38-
end
39-
40-
it "renders the body" do
41-
expect(face_to_face_mail.body.encoded).to include(user.first_name.to_s)
42-
end
43-
44-
it "includes the subject in the email" do
45-
expect(face_to_face_mail.body.encoded).to include("<title>#{face_to_face_subject}</title>")
46-
end
47-
end
48-
4931
describe "completed online course email" do
5032
it "renders the headers" do
51-
expect(online_mail.subject).to include(online_subject)
52-
expect(online_mail.to).to eq([user.email])
53-
expect(online_mail.from).to eq(["noreply@teachcomputing.org"])
33+
expect(course_mail.subject).to include(course_subject)
34+
expect(course_mail.to).to eq([user.email])
35+
expect(course_mail.from).to eq(["noreply@teachcomputing.org"])
5436
end
5537

5638
it "renders the body" do
57-
expect(online_mail.body.encoded).to include(user.first_name.to_s)
39+
expect(course_mail.body.encoded).to include(user.first_name.to_s)
5840
end
5941

6042
it "includes the subject in the email" do
61-
expect(online_mail.body.encoded).to include("<title>#{online_subject}</title>")
43+
expect(course_mail.body.encoded).to include("<title>#{course_subject}</title>")
6244
end
6345
end
6446
end

0 commit comments

Comments
 (0)