-
-
Notifications
You must be signed in to change notification settings - Fork 926
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Capture logging and include assertion for expected output
- Loading branch information
1 parent
6854947
commit 686a9c1
Showing
1 changed file
with
5 additions
and
2 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 |
---|---|---|
|
@@ -9,7 +9,7 @@ class MailerTest < ActionMailer::TestCase | |
@user = create(:user) | ||
create(:rubygem, owners: [@user], downloads: MIN_DOWNLOADS_FOR_MFA_RECOMMENDATION_POLICY) | ||
|
||
Rake::Task["mfa_policy:announce_recommendation"].invoke | ||
@io_output, _error = capture_io { Rake::Task["mfa_policy:announce_recommendation"].execute } | ||
Delayed::Worker.new.work_off | ||
end | ||
|
||
|
@@ -20,6 +20,7 @@ class MailerTest < ActionMailer::TestCase | |
assert_equal ["[email protected]"], email.from | ||
assert_equal "Please enable multi-factor authentication on your RubyGems account", email.subject | ||
assert_match "Thank you for making the RubyGems ecosystem more secure", email.text_part.body.to_s | ||
assert_match "Sending 1 MFA announcement email", @io_output | ||
end | ||
end | ||
|
||
|
@@ -28,7 +29,8 @@ class MailerTest < ActionMailer::TestCase | |
user = create(:user, mfa_level: "disabled") | ||
create(:rubygem, owners: [user], downloads: MIN_DOWNLOADS_FOR_MFA_REQUIRED_POLICY) | ||
|
||
Rake::Task["mfa_policy:reminder_enable_mfa"].invoke | ||
@io_output, _error = capture_io { Rake::Task["mfa_policy:reminder_enable_mfa"].execute } | ||
|
||
Delayed::Worker.new.work_off | ||
|
||
refute_empty ActionMailer::Base.deliveries | ||
|
@@ -37,6 +39,7 @@ class MailerTest < ActionMailer::TestCase | |
assert_equal ["[email protected]"], email.from | ||
assert_equal "[Action Required] Enable multi-factor authentication on your RubyGems account by August 15", email.subject | ||
assert_match "Thank you for making the RubyGems ecosystem more secure", email.text_part.body.to_s | ||
assert_match "Sending 1 MFA reminder email", @io_output | ||
end | ||
end | ||
|
||
|