summaryrefslogtreecommitdiff
path: root/spec/migrations/enqueue_verify_pages_domain_workers_spec.rb
blob: afcaefa0591751281ec9b4d9d64df6590a747cc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20180216121030_enqueue_verify_pages_domain_workers')

describe EnqueueVerifyPagesDomainWorkers, :sidekiq, :migration do
  around do |example|
    Sidekiq::Testing.fake! do
      example.run
    end
  end

  describe '#up' do
    it 'enqueues a verification worker for every domain' do
      domains = 1.upto(3).map { |i| PagesDomain.create!(domain: "my#{i}.domain.com") }

      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