debian-mirror-gitlab/spec/services/pages/delete_service_spec.rb

57 lines
1.4 KiB
Ruby
Raw Normal View History

2020-01-01 13:55:28 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-05-27 22:25:52 +05:30
RSpec.describe Pages::DeleteService, feature_category: :pages do
2021-03-11 19:13:27 +05:30
let_it_be(:admin) { create(:admin) }
2020-01-01 13:55:28 +05:30
2022-08-27 11:52:29 +05:30
let(:project) { create(:project, path: "my.project") }
let(:service) { described_class.new(project, admin) }
2020-01-01 13:55:28 +05:30
2021-03-11 19:13:27 +05:30
before do
project.mark_pages_as_deployed
end
2021-09-04 01:27:46 +05:30
it 'marks pages as not deployed' do
expect do
service.execute
end.to change { project.reload.pages_deployed? }.from(true).to(false)
end
it 'deletes all domains' do
domain = create(:pages_domain, project: project)
unrelated_domain = create(:pages_domain)
2021-03-11 19:13:27 +05:30
service.execute
2021-09-04 01:27:46 +05:30
expect(PagesDomain.find_by_id(domain.id)).to eq(nil)
expect(PagesDomain.find_by_id(unrelated_domain.id)).to be
2021-03-11 19:13:27 +05:30
end
2020-11-24 15:15:51 +05:30
2021-03-11 19:13:27 +05:30
it 'schedules a destruction of pages deployments' do
expect(DestroyPagesDeploymentsWorker).to(
receive(:perform_async).with(project.id)
)
2020-01-01 13:55:28 +05:30
2021-03-11 19:13:27 +05:30
service.execute
end
it 'removes pages deployments', :sidekiq_inline do
create(:pages_deployment, project: project)
2020-11-24 15:15:51 +05:30
2021-03-11 19:13:27 +05:30
expect do
service.execute
end.to change { PagesDeployment.count }.by(-1)
2020-11-24 15:15:51 +05:30
end
2022-07-23 23:45:48 +05:30
it 'publishes a ProjectDeleted event with project id and namespace id' do
2022-08-13 15:12:31 +05:30
expected_data = {
project_id: project.id,
namespace_id: project.namespace_id,
root_namespace_id: project.root_namespace.id
}
2022-07-23 23:45:48 +05:30
expect { service.execute }.to publish_event(Pages::PageDeletedEvent).with(expected_data)
end
2020-01-01 13:55:28 +05:30
end