summaryrefslogtreecommitdiff
path: root/spec/workers/pages_domain_removal_cron_worker_spec.rb
blob: 2408ad541897be210de53a1eeb592bcf59e6f521 (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
# frozen_string_literal: true

require 'spec_helper'

describe PagesDomainRemovalCronWorker do
  subject(:worker) { described_class.new }

  describe '#perform' do
    context 'when there is domain which should be removed' do
      let!(:domain_for_removal) { create(:pages_domain, :should_be_removed) }

      it 'removes domain' do
        expect { worker.perform }.to change { PagesDomain.count }.by(-1)
        expect(PagesDomain.exists?).to eq(false)
      end
    end

    context 'where there is a domain which scheduled for removal in the future' do
      let!(:domain_for_removal) { create(:pages_domain, :scheduled_for_removal) }

      it 'does not remove pages domain' do
        expect { worker.perform }.not_to change { PagesDomain.count }
        expect(PagesDomain.find_by(domain: domain_for_removal.domain)).to be_present
      end
    end
  end
end