2019-10-22 03:06:00 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-02-06 13:25:46 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
require Rails.root.join('db', 'post_migrate', '20180216121030_enqueue_verify_pages_domain_workers')
|
|
|
|
|
2020-03-11 21:09:19 +00:00
|
|
|
describe EnqueueVerifyPagesDomainWorkers do
|
2018-02-06 13:25:46 +00:00
|
|
|
around do |example|
|
|
|
|
Sidekiq::Testing.fake! do
|
|
|
|
example.run
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-06-06 19:14:09 +00:00
|
|
|
let(:domains_table) { table(:pages_domains) }
|
|
|
|
|
2018-02-06 13:25:46 +00:00
|
|
|
describe '#up' do
|
|
|
|
it 'enqueues a verification worker for every domain' do
|
2019-06-06 19:14:09 +00:00
|
|
|
domains = Array.new(3) do |i|
|
|
|
|
domains_table.create!(domain: "my#{i}.domain.com", verification_code: "123#{i}")
|
|
|
|
end
|
2018-02-06 13:25:46 +00:00
|
|
|
|
|
|
|
expect { migrate! }.to change(PagesDomainVerificationWorker.jobs, :size).by(3)
|
|
|
|
|
|
|
|
enqueued_ids = PagesDomainVerificationWorker.jobs.map { |job| job['args'] }
|
|
|
|
expected_ids = domains.map { |domain| [domain.id] }
|
|
|
|
|
|
|
|
expect(enqueued_ids).to match_array(expected_ids)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|