2019-12-09 04:08:00 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 11:08:50 -04:00
|
|
|
RSpec.describe Pages::DeleteService do
|
2020-08-25 20:10:31 -04:00
|
|
|
shared_examples 'remove pages' do
|
|
|
|
let_it_be(:project) { create(:project, path: "my.project")}
|
|
|
|
let_it_be(:admin) { create(:admin) }
|
|
|
|
let_it_be(:domain) { create(:pages_domain, project: project) }
|
|
|
|
let_it_be(:service) { described_class.new(project, admin)}
|
2019-12-09 04:08:00 -05:00
|
|
|
|
2020-08-25 20:10:31 -04:00
|
|
|
it 'deletes published pages' do
|
|
|
|
expect_any_instance_of(Gitlab::PagesTransfer).to receive(:rename_project).and_return true
|
|
|
|
expect(PagesWorker).to receive(:perform_in).with(5.minutes, :remove, project.namespace.full_path, anything)
|
2019-12-09 04:08:00 -05:00
|
|
|
|
2020-08-25 20:10:31 -04:00
|
|
|
Sidekiq::Testing.inline! { service.execute }
|
2019-12-09 04:08:00 -05:00
|
|
|
|
2020-08-25 20:10:31 -04:00
|
|
|
expect(project.reload.pages_metadatum.deployed?).to be(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'deletes all domains' do
|
|
|
|
expect(project.pages_domains.count).to be 1
|
|
|
|
|
|
|
|
Sidekiq::Testing.inline! { service.execute }
|
|
|
|
|
|
|
|
expect(project.reload.pages_domains.count).to be 0
|
|
|
|
end
|
2019-12-09 04:08:00 -05:00
|
|
|
end
|
|
|
|
|
2020-08-25 20:10:31 -04:00
|
|
|
context 'with feature flag enabled' do
|
|
|
|
before do
|
|
|
|
expect(PagesRemoveWorker).to receive(:perform_async).and_call_original
|
|
|
|
end
|
2019-12-09 04:08:00 -05:00
|
|
|
|
2020-08-25 20:10:31 -04:00
|
|
|
it_behaves_like 'remove pages'
|
2019-12-09 04:08:00 -05:00
|
|
|
end
|
|
|
|
end
|