2021-01-29 00:20:46 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
RSpec.describe Pages::DestroyDeploymentsService, feature_category: :pages do
|
|
|
|
let_it_be(:project) { create(:project) }
|
2021-01-29 00:20:46 +05:30
|
|
|
let!(:old_deployments) { create_list(:pages_deployment, 2, project: project) }
|
|
|
|
let!(:last_deployment) { create(:pages_deployment, project: project) }
|
|
|
|
let!(:newer_deployment) { create(:pages_deployment, project: project) }
|
|
|
|
let!(:deployment_from_another_project) { create(:pages_deployment) }
|
|
|
|
|
|
|
|
it 'destroys all deployments of the project' do
|
2023-04-23 21:23:45 +05:30
|
|
|
expect { described_class.new(project).execute }
|
|
|
|
.to change { PagesDeployment.count }.by(-4)
|
2021-01-29 00:20:46 +05:30
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
expect(deployment_from_another_project.reload).to be_persisted
|
2021-01-29 00:20:46 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'destroy only deployments older than last deployment if it is provided' do
|
2023-04-23 21:23:45 +05:30
|
|
|
expect { described_class.new(project, last_deployment.id).execute }
|
|
|
|
.to change { PagesDeployment.count }.by(-2)
|
2021-01-29 00:20:46 +05:30
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
expect(last_deployment.reload).to be_persisted
|
|
|
|
expect(newer_deployment.reload).to be_persisted
|
|
|
|
expect(deployment_from_another_project.reload).to be_persisted
|
2021-01-29 00:20:46 +05:30
|
|
|
end
|
|
|
|
end
|