2020-01-11 10:07:49 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 02:09:01 -04:00
|
|
|
RSpec.describe ContainerExpirationPolicyService do
|
2020-01-11 10:07:49 -05:00
|
|
|
let_it_be(:user) { create(:user) }
|
|
|
|
let_it_be(:container_expiration_policy) { create(:container_expiration_policy, :runnable) }
|
2021-06-28 23:07:32 -04:00
|
|
|
|
2020-01-11 10:07:49 -05:00
|
|
|
let(:project) { container_expiration_policy.project }
|
|
|
|
let(:container_repository) { create(:container_repository, project: project) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
project.add_maintainer(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#execute' do
|
|
|
|
subject { described_class.new(project, user).execute(container_expiration_policy) }
|
|
|
|
|
|
|
|
it 'kicks off a cleanup worker for the container repository' do
|
|
|
|
expect(CleanupContainerRepositoryWorker).to receive(:perform_async)
|
2020-02-13 10:08:52 -05:00
|
|
|
.with(nil, container_repository.id, hash_including(container_expiration_policy: true))
|
2020-01-11 10:07:49 -05:00
|
|
|
|
|
|
|
subject
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'sets next_run_at on the container_expiration_policy' do
|
|
|
|
subject
|
|
|
|
|
|
|
|
expect(container_expiration_policy.next_run_at).to be > Time.zone.now
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|