Reduce round trips in admin/disputes/appeals spec (#29234)

main
Matt Jankowski 2024-02-16 08:46:28 -05:00 committed by GitHub
parent 3454fcbd71
commit 1946e171e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 14 additions and 17 deletions

View File

@ -30,21 +30,19 @@ RSpec.describe Admin::Disputes::AppealsController do
end end
describe 'POST #approve' do describe 'POST #approve' do
subject { post :approve, params: { id: appeal.id } }
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) } let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
before do it 'redirects back to the strike page and notifies target account about approved appeal', :sidekiq_inline do
post :approve, params: { id: appeal.id } subject
end
it 'unsuspends a suspended account' do expect(response)
expect(target_account.reload.suspended?).to be false .to redirect_to(disputes_strike_path(appeal.strike))
end
it 'redirects back to the strike page' do expect(target_account.reload)
expect(response).to redirect_to(disputes_strike_path(appeal.strike)) .to_not be_suspended
end
it 'notifies target account about approved appeal', :sidekiq_inline do
expect(UserMailer.deliveries.size).to eq(1) expect(UserMailer.deliveries.size).to eq(1)
expect(UserMailer.deliveries.first.to.first).to eq(target_account.user.email) expect(UserMailer.deliveries.first.to.first).to eq(target_account.user.email)
expect(UserMailer.deliveries.first.subject).to eq(I18n.t('user_mailer.appeal_approved.subject', date: I18n.l(appeal.created_at))) expect(UserMailer.deliveries.first.subject).to eq(I18n.t('user_mailer.appeal_approved.subject', date: I18n.l(appeal.created_at)))
@ -52,17 +50,16 @@ RSpec.describe Admin::Disputes::AppealsController do
end end
describe 'POST #reject' do describe 'POST #reject' do
subject { post :reject, params: { id: appeal.id } }
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) } let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
before do it 'redirects back to the strike page and notifies target account about rejected appeal', :sidekiq_inline do
post :reject, params: { id: appeal.id } subject
end
it 'redirects back to the strike page' do expect(response)
expect(response).to redirect_to(disputes_strike_path(appeal.strike)) .to redirect_to(disputes_strike_path(appeal.strike))
end
it 'notifies target account about rejected appeal', :sidekiq_inline do
expect(UserMailer.deliveries.size).to eq(1) expect(UserMailer.deliveries.size).to eq(1)
expect(UserMailer.deliveries.first.to.first).to eq(target_account.user.email) expect(UserMailer.deliveries.first.to.first).to eq(target_account.user.email)
expect(UserMailer.deliveries.first.subject).to eq(I18n.t('user_mailer.appeal_rejected.subject', date: I18n.l(appeal.created_at))) expect(UserMailer.deliveries.first.subject).to eq(I18n.t('user_mailer.appeal_rejected.subject', date: I18n.l(appeal.created_at)))