Commit a43dbc2f authored by Stan Hu's avatar Stan Hu

Merge branch '228876-fix-migration-assertions' into 'master'

Assert on method calls instead of ActiveJob internals

Closes #228876

See merge request gitlab-org/gitlab!36836
parents 2f5cddea 62b09dd1
...@@ -98,65 +98,26 @@ RSpec.describe Gitlab::BackgroundMigration::WrongfullyConfirmedEmailUnconfirmer, ...@@ -98,65 +98,26 @@ RSpec.describe Gitlab::BackgroundMigration::WrongfullyConfirmedEmailUnconfirmer,
end end
context 'enqueued jobs' do context 'enqueued jobs' do
let(:user_1_gid) { User.find(user_needs_migration_1.id).to_gid.to_s } let(:user_1) { User.find(user_needs_migration_1.id) }
let(:user_2_gid) { User.find(user_needs_migration_2.id).to_gid.to_s } 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_1) { Email.find(bad_email_1.id) }
let(:email_2_gid) { Email.find(bad_email_2.id).to_gid.to_s } let(:email_2) { Email.find(bad_email_2.id) }
it 'enqueues the email confirmation and the unconfirm notification mailer jobs' do 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 subject
expect(enqueued_jobs.size).to eq(6) 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)
expected_job_arguments = [
[ expect(Gitlab::BackgroundMigration::Mailers::UnconfirmMailer).to have_received(:unconfirm_notification_email).with(user_1)
'DeviseMailer', expect(DeviseMailer).to have_received(:confirmation_instructions).with(user_1, user_1.confirmation_token)
'confirmation_instructions',
'deliver_now', expect(Gitlab::BackgroundMigration::Mailers::UnconfirmMailer).to have_received(:unconfirm_notification_email).with(user_2)
{ "_aj_globalid" => email_1_gid }, expect(DeviseMailer).to have_received(:confirmation_instructions).with(user_2, user_2.confirmation_token)
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
end end
end 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