Commit 088ca5c3 authored by charlie ablett's avatar charlie ablett

Remove project.owner from container expiry worker

parent 68755b38
......@@ -57,7 +57,7 @@ class ContainerExpirationPolicyWorker # rubocop:disable Scalability/IdempotentWo
def perform_unthrottled
with_runnable_policy(preloaded: true) do |policy|
with_context(project: policy.project,
user: policy.project.owner) do |project:, user:|
user: nil) do |project:, user:|
ContainerExpirationPolicyService.new(project, user)
.execute(policy)
end
......
......@@ -60,12 +60,11 @@ RSpec.describe ContainerExpirationPolicyWorker do
context 'with container expiration policies' do
let_it_be(:container_expiration_policy, reload: true) { create(:container_expiration_policy, :runnable) }
let_it_be(:container_repository) { create(:container_repository, project: container_expiration_policy.project) }
let_it_be(:user) { container_expiration_policy.project.owner }
context 'a valid policy' do
it 'runs the policy' do
expect(ContainerExpirationPolicyService)
.to receive(:new).with(container_expiration_policy.project, user).and_call_original
.to receive(:new).with(container_expiration_policy.project, nil).and_call_original
expect(CleanupContainerRepositoryWorker).to receive(:perform_async).once.and_call_original
expect { subject }.not_to raise_error
......@@ -102,7 +101,7 @@ RSpec.describe ContainerExpirationPolicyWorker do
end
it 'disables the policy and tracks an error' do
expect(ContainerExpirationPolicyService).not_to receive(:new).with(container_expiration_policy, user)
expect(ContainerExpirationPolicyService).not_to receive(:new).with(container_expiration_policy, nil)
expect(Gitlab::ErrorTracking).to receive(:log_exception).with(instance_of(described_class::InvalidPolicyError), container_expiration_policy_id: container_expiration_policy.id)
expect { subject }.to change { container_expiration_policy.reload.enabled }.from(true).to(false)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment