Merge commit '3d8d5f6dc7625d9638cc2e3387247442225d4e3f' into glitch-soc/merge-upstream

This commit is contained in:
Claire
2026-03-05 18:21:07 +01:00
91 changed files with 1551 additions and 690 deletions

View File

@@ -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

View File

@@ -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

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

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

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)

View File

@@ -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

View File

@@ -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

View File

@@ -50,9 +50,8 @@ RSpec.describe 'Auth Passwords' do
def submit_email_reset
fill_in 'user_email', with: user.email
click_on I18n.t('auth.reset_password')
open_last_email
visit_in_email(I18n.t('devise.mailer.reset_password_instructions.action'))
emails = capture_emails { click_on I18n.t('auth.reset_password') }
visit email_links(emails.first).first
end
def set_new_password

View File

@@ -27,17 +27,9 @@ RSpec.describe 'Dispute Appeals' do
# Valid with text
fill_in 'appeal_text', with: 'It wasnt me this time!'
emails = capture_emails do
expect { submit_form }
.to change(Appeal, :count).by(1)
end
expect(emails)
.to contain_exactly(
have_attributes(
to: contain_exactly(admin.email),
subject: eq(new_appeal_subject)
)
)
expect { submit_form }
.to change(Appeal, :count).by(1)
.and send_email(to: admin.email, subject: new_appeal_subject)
expect(page)
.to have_content(I18n.t('disputes.strikes.appealed_msg'))
end

View File

@@ -24,17 +24,12 @@ RSpec.describe 'Settings TwoFactorAuthenticationMethods' do
# Fill in challenge form
fill_in 'form_challenge_current_password', with: user.password
emails = capture_emails do
expect { click_on I18n.t('challenge.confirm') }
.to change { user.reload.otp_required_for_login }.to(false)
end
expect { click_on I18n.t('challenge.confirm') }
.to change { user.reload.otp_required_for_login }.to(false)
.and send_email(to: user.email, subject: I18n.t('devise.mailer.two_factor_disabled.subject'))
expect(page)
.to have_content(I18n.t('two_factor_authentication.disabled_success'))
expect(emails.first)
.to be_present
.and(deliver_to(user.email))
.and(have_subject(I18n.t('devise.mailer.two_factor_disabled.subject')))
end
end
end