debian-mirror-gitlab/spec/services/container_expiration_policy_service_spec.rb

33 lines
975 B
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe ContainerExpirationPolicyService do
2020-03-13 15:44:24 +05:30
let_it_be(:user) { create(:user) }
let_it_be(:container_expiration_policy) { create(:container_expiration_policy, :runnable) }
2021-09-30 23:02:18 +05:30
2020-03-13 15:44:24 +05:30
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)
.with(nil, container_repository.id, hash_including(container_expiration_policy: true))
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