Replace email_spec gem with built-in matchers (#38079)

This commit is contained in:
Matt Jankowski authored and GitHub committed 2026-03-05 14:42:21 +00:00
1 parent 5d4271a3cc
commit 4e3866dbaf
18 files changed
+231 -241

No files matched your search

@@ -14,13 +14,10 @@ RSpec.describe 'Admin Announcement Mail Distributions' do
expect(page)
.to have_title(I18n.t('admin.announcements.preview.title'))
emails = capture_emails do
expect do
expect { click_on I18n.t('admin.terms_of_service.preview.send_to_all', count: 1, display_count: 1) }
.to(change { announcement.reload.notification_sent_at })
end
expect(emails.first)
.to be_present
.and(deliver_to(user.email))
end.to send_email(to: user.email)
expect(page)
.to have_title(I18n.t('admin.announcements.title'))
end
@@ -14,10 +14,8 @@ RSpec.describe 'Admin TermsOfService Tests' do
expect(page)
.to have_title(I18n.t('admin.announcements.preview.title'))
emails = capture_emails { click_on I18n.t('admin.terms_of_service.preview.send_preview', email: user.email) }
expect(emails.first)
.to be_present
.and(deliver_to(user.email))
expect { click_on I18n.t('admin.terms_of_service.preview.send_preview', email: user.email) }
.to send_email(to: user.email)
expect(page)
.to have_title(I18n.t('admin.announcements.title'))
end
+2 -5
View File
@@ -16,11 +16,8 @@ RSpec.describe 'Admin Change Emails' do
.to have_title(I18n.t('admin.accounts.change_email.title', username: user.account.username))
fill_in 'user_unconfirmed_email', with: 'test@host.example'
emails = capture_emails { process_change_email }
expect(emails.first)
.to be_present
.and(deliver_to('test@host.example'))
.and(have_subject(/Confirm email/))
expect { process_change_email }
.to send_email(to: 'test@host.example', subject: /Confirm email/)
expect(page)
.to have_title(user.account.pretty_acct)
end
+2 -5
View File
@@ -36,14 +36,11 @@ RSpec.describe 'Admin Confirmations' do
it 'resends the confirmation mail' do
visit admin_account_path(id: user.account.id)
emails = capture_emails { resend_confirmation }
expect { resend_confirmation }
.to send_email(to: user.email)
expect(page)
.to have_title(I18n.t('admin.accounts.title'))
.and have_content(I18n.t('admin.accounts.resend_confirmation.success'))
expect(emails.first)
.to be_present
.and deliver_to(user.email)
end
end
+4 -13
View File
@@ -8,20 +8,11 @@ RSpec.describe 'Admin::Reset' do
sign_in admin_user
visit admin_account_path(account.id)
emails = capture_emails do
expect do
expect { submit_reset }
.to change(Admin::ActionLog.where(target: account.user), :count).by(1)
end
expect(emails.first)
.to be_present
.and(deliver_to(account.user.email))
.and(have_subject(password_change_subject))
expect(emails.last)
.to be_present
.and(deliver_to(account.user.email))
.and(have_subject(reset_instructions_subject))
.to send_email(to: account.user.email, subject: password_change_subject)
.and send_email(to: account.user.email, subject: reset_instructions_subject)
end.to change(Admin::ActionLog.where(target: account.user), :count).by(1)
expect(page)
.to have_content(account.username)
@@ -14,13 +14,9 @@ RSpec.describe 'Admin TermsOfService Distributions' do
expect(page)
.to have_title(I18n.t('admin.terms_of_service.preview.title'))
emails = capture_emails do
expect { click_on I18n.t('admin.terms_of_service.preview.send_to_all', count: 1, display_count: 1) }
.to(change { terms_of_service.reload.notification_sent_at })
end
expect(emails.first)
.to be_present
.and(deliver_to(user.email))
expect { click_on I18n.t('admin.terms_of_service.preview.send_to_all', count: 1, display_count: 1) }
.to change { terms_of_service.reload.notification_sent_at }
.and send_email(to: user.email)
expect(page)
.to have_title(I18n.t('admin.terms_of_service.title'))
end
@@ -14,10 +14,8 @@ RSpec.describe 'Admin TermsOfService Tests' do
expect(page)
.to have_title(I18n.t('admin.terms_of_service.preview.title'))
emails = capture_emails { click_on I18n.t('admin.terms_of_service.preview.send_preview', email: user.email) }
expect(emails.first)
.to be_present
.and(deliver_to(user.email))
expect { click_on I18n.t('admin.terms_of_service.preview.send_preview', email: user.email) }
.to send_email(to: user.email)
expect(page)
.to have_title(I18n.t('admin.terms_of_service.preview.title'))
end