Commit 61c77b7c authored by Tetiana Chupryna's avatar Tetiana Chupryna

Merge branch '350603-cablett-container-expiry-user' into 'master'

Remove project.owner from container expiry worker

See merge request gitlab-org/gitlab!78512
parents aa665ddf 088ca5c3
...@@ -57,7 +57,7 @@ class ContainerExpirationPolicyWorker # rubocop:disable Scalability/IdempotentWo ...@@ -57,7 +57,7 @@ class ContainerExpirationPolicyWorker # rubocop:disable Scalability/IdempotentWo
def perform_unthrottled def perform_unthrottled
with_runnable_policy(preloaded: true) do |policy| with_runnable_policy(preloaded: true) do |policy|
with_context(project: policy.project, with_context(project: policy.project,
user: policy.project.owner) do |project:, user:| user: nil) do |project:, user:|
ContainerExpirationPolicyService.new(project, user) ContainerExpirationPolicyService.new(project, user)
.execute(policy) .execute(policy)
end end
......
...@@ -60,12 +60,11 @@ RSpec.describe ContainerExpirationPolicyWorker do ...@@ -60,12 +60,11 @@ RSpec.describe ContainerExpirationPolicyWorker do
context 'with container expiration policies' do context 'with container expiration policies' do
let_it_be(:container_expiration_policy, reload: true) { create(:container_expiration_policy, :runnable) } 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(:container_repository) { create(:container_repository, project: container_expiration_policy.project) }
let_it_be(:user) { container_expiration_policy.project.owner }
context 'a valid policy' do context 'a valid policy' do
it 'runs the policy' do it 'runs the policy' do
expect(ContainerExpirationPolicyService) 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(CleanupContainerRepositoryWorker).to receive(:perform_async).once.and_call_original
expect { subject }.not_to raise_error expect { subject }.not_to raise_error
...@@ -102,7 +101,7 @@ RSpec.describe ContainerExpirationPolicyWorker do ...@@ -102,7 +101,7 @@ RSpec.describe ContainerExpirationPolicyWorker do
end end
it 'disables the policy and tracks an error' do 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(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) 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