Skip to content

Commit

Permalink
add comments to document mail job spec setup
Browse files Browse the repository at this point in the history
  • Loading branch information
jack-coggin committed Sep 5, 2023
1 parent 5fa18c6 commit ac451d1
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions spec/jobs/complete_registration_mail_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
RSpec.describe CompleteRegistrationMailJob do
let(:template) { :complete_registration }

# Must have confirmed email 4 weeks ago and not have completed registration
let(:included) do
create_list :user, 3, confirmed_at: 4.weeks.ago
end
Expand Down
4 changes: 4 additions & 0 deletions spec/jobs/continue_training_mail_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
let(:included) { [user] }
let(:excluded) { [user_2] }

# Must have started, but not completed training.
# Must be 4 weeks since their last visit
# `user_2` won't be included because they have a visit from 2 weeks ago
before do
create :visit,
id: 9,
Expand All @@ -35,6 +38,7 @@
user_id: user_2.id,
started_at: 2.weeks.ago

# Travel to 4 weeks ago so that the module start event won't count as a recent visit
travel_to 4.weeks.ago
start_module(alpha)
travel_back
Expand Down
7 changes: 5 additions & 2 deletions spec/jobs/new_module_mail_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@
include_context 'with progress'

let(:template) { :new_module }

let(:included) { [user] }

let(:excluded) do
create_list :user, 2, :registered, confirmed_at: 4.weeks.ago
end

# Recipients must have completed all available modules - in this case, alpha and bravo
before do
# Create records for the previously released modules completed by the recipients
# Each `module_release` must have a corresponding `release` record
create(:release, id: 1)
create(:module_release, release_id: 1, module_position: 1, name: 'alpha')

create(:release, id: 2)
create(:module_release, release_id: 1, module_position: 2, name: 'bravo')

# This will complete the alpha and bravo modules for `user`
complete_module(alpha, 1.minute)
complete_module(bravo, 1.minute)
end
Expand Down
1 change: 1 addition & 0 deletions spec/jobs/start_training_mail_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
RSpec.describe StartTrainingMailJob do
let(:template) { :start_training }

# Must have confirmed email 4 weeks ago, completed registration and not have started training
let(:included) do
create_list :user, 3, :registered, confirmed_at: 4.weeks.ago
end
Expand Down
6 changes: 5 additions & 1 deletion spec/models/data/user_overview_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,20 @@

let(:release_1) { create(:release) }

# This is a mix of things and perhaps could be annotated
before do
# create records for the previously released modules completed by the `new_module_mail_recipients`
create(:module_release, release_id: release_1.id, module_position: 1, name: 'alpha')
create(:module_release, release_id: release_1.id, module_position: 2, name: 'bravo')
create(:module_release, release_id: release_1.id, module_position: 3, name: 'charlie')
# create notes for the `with_notes` and `without_notes` users
create(:note, user: user_1)
create(:note, user: user_2)
create(:note, user: user_3)
# A user who has completed all available modules and will receive the new module mail
create(:user, :registered, module_time_to_completion: { alpha: 2, charlie: 1, bravo: 3 })
# A user who confirmed their email 4 weeks ago will receive the complete registration mail
create(:user, :confirmed, confirmed_at: 4.weeks.ago)
# A registered user who will receive the start training mail
create(:user, :registered, confirmed_at: 4.weeks.ago)
end

Expand Down

0 comments on commit ac451d1

Please sign in to comment.