Commit 62b09dd1 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Assert on method calls instead of ActiveJob internals

ActiveJob argument serialization may change and cause spec failures
parent 2808f734
......@@ -98,65 +98,26 @@ RSpec.describe Gitlab::BackgroundMigration::WrongfullyConfirmedEmailUnconfirmer,
end
context 'enqueued jobs' do
let(:user_1_gid) { User.find(user_needs_migration_1.id).to_gid.to_s }
let(:user_2_gid) { User.find(user_needs_migration_2.id).to_gid.to_s }
let(:user_1) { User.find(user_needs_migration_1.id) }
let(:user_2) { User.find(user_needs_migration_2.id) }
let(:email_1_gid) { Email.find(bad_email_1.id).to_gid.to_s }
let(:email_2_gid) { Email.find(bad_email_2.id).to_gid.to_s }
let(:email_1) { Email.find(bad_email_1.id) }
let(:email_2) { Email.find(bad_email_2.id) }
it 'enqueues the email confirmation and the unconfirm notification mailer jobs' do
allow(DeviseMailer).to receive(:confirmation_instructions).and_call_original
allow(Gitlab::BackgroundMigration::Mailers::UnconfirmMailer).to receive(:unconfirm_notification_email).and_call_original
subject
expect(enqueued_jobs.size).to eq(6)
expected_job_arguments = [
[
'DeviseMailer',
'confirmation_instructions',
'deliver_now',
{ "_aj_globalid" => email_1_gid },
bad_email_1.reload.confirmation_token
],
[
'DeviseMailer',
'confirmation_instructions',
'deliver_now',
{ "_aj_globalid" => email_2_gid },
bad_email_2.reload.confirmation_token
],
[
'DeviseMailer',
'confirmation_instructions',
'deliver_now',
{ "_aj_globalid" => user_1_gid },
user_needs_migration_1.reload.confirmation_token
],
[
'Gitlab::BackgroundMigration::Mailers::UnconfirmMailer',
'unconfirm_notification_email',
'deliver_now',
{ "_aj_globalid" => user_1_gid }
],
[
'DeviseMailer',
'confirmation_instructions',
'deliver_now',
{ "_aj_globalid" => user_2_gid },
user_needs_migration_2.reload.confirmation_token
],
[
'Gitlab::BackgroundMigration::Mailers::UnconfirmMailer',
'unconfirm_notification_email',
'deliver_now',
{ "_aj_globalid" => user_2_gid }
]
]
all_job_arguments = enqueued_jobs.map { |job| job["arguments"] }
expected_job_arguments.each do |job_arguments|
expect(all_job_arguments).to include(job_arguments)
end
expect(DeviseMailer).to have_received(:confirmation_instructions).with(email_1, email_1.confirmation_token)
expect(DeviseMailer).to have_received(:confirmation_instructions).with(email_2, email_2.confirmation_token)
expect(Gitlab::BackgroundMigration::Mailers::UnconfirmMailer).to have_received(:unconfirm_notification_email).with(user_1)
expect(DeviseMailer).to have_received(:confirmation_instructions).with(user_1, user_1.confirmation_token)
expect(Gitlab::BackgroundMigration::Mailers::UnconfirmMailer).to have_received(:unconfirm_notification_email).with(user_2)
expect(DeviseMailer).to have_received(:confirmation_instructions).with(user_2, user_2.confirmation_token)
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment