-
Notifications
You must be signed in to change notification settings - Fork 0
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
4 changed files
with
119 additions
and
90 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
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 |
---|---|---|
|
@@ -6,31 +6,33 @@ class SchedulerReportingEmailsTest < ActionDispatch::IntegrationTest | |
setup do | ||
Rake::Task.clear | ||
Enrollchat::Application.load_tasks | ||
Time.zone = "Eastern Time (US & Canada)" | ||
end | ||
|
||
teardown do | ||
Rake::Task.clear | ||
Time.zone = "UTC" | ||
end | ||
|
||
# schedule old term purge rake task | ||
test "schedule old term purge email is generated" do | ||
travel_to Time.zone.local(2022, 1, 10, 10, 4, 44) do | ||
assert_emails 1 do | ||
Rake::Task['scheduler:schedule_old_term_purge'].invoke | ||
Time.use_zone("Eastern Time (US & Canada)") do | ||
travel_to Time.zone.local(2022, 1, 10, 10, 4, 44) do | ||
assert_emails 1 do | ||
Rake::Task['scheduler:schedule_old_term_purge'].invoke | ||
end | ||
end | ||
end | ||
end | ||
|
||
test "schedule old term purge email content" do | ||
travel_to Time.zone.local(2022, 1, 10, 10, 4, 44) do | ||
Rake::Task['scheduler:schedule_old_term_purge'].invoke | ||
Time.use_zone("Eastern Time (US & Canada)") do | ||
travel_to Time.zone.local(2022, 1, 10, 10, 4, 44) do | ||
Rake::Task['scheduler:schedule_old_term_purge'].invoke | ||
end | ||
email = ActionMailer::Base.deliveries.last | ||
assert_equal ["[email protected]"], email.from | ||
assert_equal ["[email protected]"], email.to | ||
assert_equal 'Terms Marked for Deletion (Triggered in test)', email.subject | ||
assert email.body.to_s.include?("<h1>Terms marked for deletion</h1><p>201810</p><p>All sections from these terms will be removed from the system in 30 days.</p>") | ||
end | ||
email = ActionMailer::Base.deliveries.last | ||
assert_equal ["[email protected]"], email.from | ||
assert_equal ["[email protected]"], email.to | ||
assert_equal 'Terms Marked for Deletion (Triggered in test)', email.subject | ||
assert email.body.to_s.include?("<h1>Terms marked for deletion</h1><p>201810</p><p>All sections from these terms will be removed from the system in 30 days.</p>") | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,13 +11,11 @@ class WorkerReportingEmailsTest < ActionDispatch::IntegrationTest | |
Enrollchat::Application.load_tasks | ||
@settings = settings(:one) | ||
@settings.update(email_delivery: 'on') | ||
Time.zone = "Eastern Time (US & Canada)" | ||
end | ||
|
||
teardown do | ||
Sidekiq::Worker.clear_all | ||
Rake::Task.clear | ||
Time.zone = "UTC" | ||
end | ||
|
||
# Daily digest worker | ||
|
@@ -70,64 +68,72 @@ class WorkerReportingEmailsTest < ActionDispatch::IntegrationTest | |
|
||
# Weekly report worker | ||
test "Weekly report emails are generated" do | ||
travel_to Time.zone.local(2018, 11, 15, 1, 4, 44) do | ||
Rake::Task['weekly_reports:send_emails'].invoke | ||
Sidekiq::Worker.drain_all | ||
assert_emails User.wanting_report.count + 1 | ||
Time.use_zone("Eastern Time (US & Canada)") do | ||
travel_to Time.zone.local(2018, 11, 15, 1, 4, 44) do | ||
Rake::Task['weekly_reports:send_emails'].invoke | ||
Sidekiq::Worker.drain_all | ||
assert_emails User.wanting_report.count + 1 | ||
end | ||
end | ||
end | ||
|
||
test "'Weekly Report Executed' email content" do | ||
recipient = users(:one) | ||
recipient_two = users(:two) | ||
recipient_three = users(:three) | ||
travel_to Time.zone.local(2018, 11, 15, 1, 4, 44) do | ||
Rake::Task['weekly_reports:send_emails'].invoke | ||
Sidekiq::Worker.drain_all | ||
email = ActionMailer::Base.deliveries.last | ||
assert_equal ["[email protected]"], email.from | ||
assert_equal ["[email protected]"], email.to | ||
assert_equal 'EnrollChat Report Task Executed (Triggered in test)', email.subject | ||
assert email.body.to_s.include?("<h1>EnrollChat Weekly Report Sent</h1>") | ||
assert email.body.to_s.include?("<p>Reports sent to:</p>") | ||
assert email.body.to_s.include?("<ul><li>#{recipient.full_name} (#{recipient.email})</li><li>#{recipient_two.full_name} (#{recipient_two.email})</li><li>#{recipient_three.full_name} (#{recipient_three.email})</li></ul>") | ||
Time.use_zone("Eastern Time (US & Canada)") do | ||
travel_to Time.zone.local(2018, 11, 15, 1, 4, 44) do | ||
Rake::Task['weekly_reports:send_emails'].invoke | ||
Sidekiq::Worker.drain_all | ||
email = ActionMailer::Base.deliveries.last | ||
assert_equal ["[email protected]"], email.from | ||
assert_equal ["[email protected]"], email.to | ||
assert_equal 'EnrollChat Report Task Executed (Triggered in test)', email.subject | ||
assert email.body.to_s.include?("<h1>EnrollChat Weekly Report Sent</h1>") | ||
assert email.body.to_s.include?("<p>Reports sent to:</p>") | ||
assert email.body.to_s.include?("<ul><li>#{recipient.full_name} (#{recipient.email})</li><li>#{recipient_two.full_name} (#{recipient_two.email})</li><li>#{recipient_three.full_name} (#{recipient_three.email})</li></ul>") | ||
end | ||
end | ||
end | ||
|
||
test "EnrollChat Report email standard content" do | ||
term = @settings.current_term | ||
travel_to Time.zone.local(2018, 11, 15, 1, 4, 44) do | ||
Rake::Task['weekly_reports:send_emails'].invoke | ||
Sidekiq::Worker.drain_all | ||
emails = ActionMailer::Base.deliveries[0..2] | ||
emails.each do |email| | ||
assert_equal ["[email protected]"], email.from | ||
assert_equal ["[email protected]"], email.to | ||
assert_equal 'EnrollChat Report (Triggered in test)', email.subject | ||
assert email.body.to_s.include?("<h1>EnrollChat Weekly Report</h1>") | ||
assert email.body.to_s.include?("<h3>Information for #{term_in_words(term)}</h3>") | ||
assert email.body.to_s.include?("<p>EnrollChat provides you with up-to-date enrollment information for the current enrollment term. Log in to gather information on each class, including whether there has been an increase or decrease in enrollment over the previous reporting period. Both the Dean's Office and you have access to this data and should use EnrollChat to regularly communicate about specific courses.<p>") | ||
assert email.body.to_s.include?("<h2>Sections With Comments</h2>") | ||
Time.use_zone("Eastern Time (US & Canada)") do | ||
travel_to Time.zone.local(2018, 11, 15, 1, 4, 44) do | ||
Rake::Task['weekly_reports:send_emails'].invoke | ||
Sidekiq::Worker.drain_all | ||
emails = ActionMailer::Base.deliveries[0..2] | ||
emails.each do |email| | ||
assert_equal ["[email protected]"], email.from | ||
assert_equal ["[email protected]"], email.to | ||
assert_equal 'EnrollChat Report (Triggered in test)', email.subject | ||
assert email.body.to_s.include?("<h1>EnrollChat Weekly Report</h1>") | ||
assert email.body.to_s.include?("<h3>Information for #{term_in_words(term)}</h3>") | ||
assert email.body.to_s.include?("<p>EnrollChat provides you with up-to-date enrollment information for the current enrollment term. Log in to gather information on each class, including whether there has been an increase or decrease in enrollment over the previous reporting period. Both the Dean's Office and you have access to this data and should use EnrollChat to regularly communicate about specific courses.<p>") | ||
assert email.body.to_s.include?("<h2>Sections With Comments</h2>") | ||
end | ||
end | ||
end | ||
end | ||
|
||
test "EnrollChat Report recipient specific content" do | ||
travel_to Time.zone.local(2018, 11, 15, 1, 4, 44) do | ||
Rake::Task['weekly_reports:send_emails'].invoke | ||
Sidekiq::Worker.drain_all | ||
emails = ActionMailer::Base.deliveries[0..2] | ||
assert emails[0].body.to_s.include?("<td>BIS</td>") | ||
assert emails[0].body.to_s.include?("<td>ENGL</td>") | ||
assert emails[0].body.to_s.include?("<td>SINT</td>") | ||
assert emails[0].body.to_s.include?("<td>CRIM</td>") | ||
assert emails[1].body.to_s.include?("<td>SINT</td>") | ||
assert emails[1].body.to_s.include?("<td>CRIM</td>") | ||
assert emails[1].body.to_s.include?("<td>PHIL</td>") | ||
assert_not emails[2].body.to_s.include?("<td>BIS</td>") | ||
assert_not emails[2].body.to_s.include?("<td>ENGL</td>") | ||
assert_not emails[2].body.to_s.include?("<td>SINT</td>") | ||
assert_not emails[2].body.to_s.include?("<td>CRIM</td>") | ||
Time.use_zone("Eastern Time (US & Canada)") do | ||
travel_to Time.zone.local(2018, 11, 15, 1, 4, 44) do | ||
Rake::Task['weekly_reports:send_emails'].invoke | ||
Sidekiq::Worker.drain_all | ||
emails = ActionMailer::Base.deliveries[0..2] | ||
assert emails[0].body.to_s.include?("<td>BIS</td>") | ||
assert emails[0].body.to_s.include?("<td>ENGL</td>") | ||
assert emails[0].body.to_s.include?("<td>SINT</td>") | ||
assert emails[0].body.to_s.include?("<td>CRIM</td>") | ||
assert emails[1].body.to_s.include?("<td>SINT</td>") | ||
assert emails[1].body.to_s.include?("<td>CRIM</td>") | ||
assert emails[1].body.to_s.include?("<td>PHIL</td>") | ||
assert_not emails[2].body.to_s.include?("<td>BIS</td>") | ||
assert_not emails[2].body.to_s.include?("<td>ENGL</td>") | ||
assert_not emails[2].body.to_s.include?("<td>SINT</td>") | ||
assert_not emails[2].body.to_s.include?("<td>CRIM</td>") | ||
end | ||
end | ||
end | ||
end |