Commit c4ece04b authored by Yorick Peterse's avatar Yorick Peterse

Merge branch 'check-project-repo-exists' into 'master'

Check if repo exists before attempting to update cache info

See merge request !3414
parents 79467437 720ef51b
......@@ -5,6 +5,9 @@ class ProjectCacheWorker
def perform(project_id)
project = Project.find(project_id)
return unless project.repository.exists?
project.update_repository_size
project.update_commit_count
......
require 'spec_helper'
describe ProjectCacheWorker do
let(:project) { create(:project) }
subject { described_class.new }
describe '#perform' do
it 'updates project cache data' do
expect_any_instance_of(Repository).to receive(:size)
expect_any_instance_of(Repository).to receive(:commit_count)
expect_any_instance_of(Project).to receive(:update_repository_size)
expect_any_instance_of(Project).to receive(:update_commit_count)
subject.perform(project.id)
end
it 'handles missing repository data' do
expect_any_instance_of(Repository).to receive(:exists?).and_return(false)
expect_any_instance_of(Repository).not_to receive(:size)
subject.perform(project.id)
end
end
end
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