Skip to content

Commit

Permalink
Use deliveries.size in mailer-related examples in controller specs (m…
Browse files Browse the repository at this point in the history
  • Loading branch information
mjankowski authored Oct 27, 2023
1 parent 1cc5129 commit 2e6bf60
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions spec/controllers/admin/disputes/appeals_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }

before do
allow(UserMailer).to receive(:appeal_approved)
.and_return(instance_double(ActionMailer::MessageDelivery, deliver_later: nil))
post :approve, params: { id: appeal.id }
end

Expand All @@ -47,16 +45,16 @@
end

it 'notifies target account about approved appeal' do
expect(UserMailer).to have_received(:appeal_approved).with(target_account.user, appeal)
expect(UserMailer.deliveries.size).to eq(1)
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)))
end
end

describe 'POST #reject' do
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }

before do
allow(UserMailer).to receive(:appeal_rejected)
.and_return(instance_double(ActionMailer::MessageDelivery, deliver_later: nil))
post :reject, params: { id: appeal.id }
end

Expand All @@ -65,7 +63,9 @@
end

it 'notifies target account about rejected appeal' do
expect(UserMailer).to have_received(:appeal_rejected).with(target_account.user, appeal)
expect(UserMailer.deliveries.size).to eq(1)
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)))
end
end
end
6 changes: 3 additions & 3 deletions spec/controllers/auth/sessions_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@

before do
allow_any_instance_of(ActionDispatch::Request).to receive(:remote_ip).and_return(current_ip)
allow(UserMailer).to receive(:suspicious_sign_in)
.and_return(instance_double(ActionMailer::MessageDelivery, deliver_later!: nil))
user.update(current_sign_in_at: 1.month.ago)
post :create, params: { user: { email: user.email, password: user.password } }
end
Expand All @@ -142,7 +140,9 @@
end

it 'sends a suspicious sign-in mail' do
expect(UserMailer).to have_received(:suspicious_sign_in).with(user, current_ip, anything, anything)
expect(UserMailer.deliveries.size).to eq(1)
expect(UserMailer.deliveries.first.to.first).to eq(user.email)
expect(UserMailer.deliveries.first.subject).to eq(I18n.t('user_mailer.suspicious_sign_in.subject'))
end
end

Expand Down

0 comments on commit 2e6bf60

Please sign in to comment.