Welcome to mirror list, hosted at ThFree Co, Russian Federation.

enqueue_verify_pages_domain_workers_spec.rb « migrations « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ffb1c04a6c574df9d6f3c806d7d5be5e5062726e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true

require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20180216121030_enqueue_verify_pages_domain_workers')

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

  let(:domains_table) { table(:pages_domains) }

  describe '#up' do
    it 'enqueues a verification worker for every domain' do
      domains = Array.new(3) do |i|
        domains_table.create!(domain: "my#{i}.domain.com", verification_code: "123#{i}")
      end

      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