diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-20 16:37:47 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-20 16:37:47 +0300 |
commit | aee0a117a889461ce8ced6fcf73207fe017f1d99 (patch) | |
tree | 891d9ef189227a8445d83f35c1b0fc99573f4380 /spec/models/lfs_objects_project_spec.rb | |
parent | 8d46af3258650d305f53b819eabf7ab18d22f59e (diff) |
Add latest changes from gitlab-org/gitlab@14-6-stable-eev14.6.0-rc42
Diffstat (limited to 'spec/models/lfs_objects_project_spec.rb')
-rw-r--r-- | spec/models/lfs_objects_project_spec.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/models/lfs_objects_project_spec.rb b/spec/models/lfs_objects_project_spec.rb index df49b60c4fa..7378beeed06 100644 --- a/spec/models/lfs_objects_project_spec.rb +++ b/spec/models/lfs_objects_project_spec.rb @@ -25,6 +25,28 @@ RSpec.describe LfsObjectsProject do end end + describe '#link_to_project!' do + it 'does not throw error when duplicate exists' do + subject + + expect do + result = described_class.link_to_project!(subject.lfs_object, subject.project) + expect(result).to be_a(LfsObjectsProject) + end.not_to change { described_class.count } + end + + it 'upserts a new entry and updates the project cache' do + new_project = create(:project) + + allow(ProjectCacheWorker).to receive(:perform_async).and_call_original + expect(ProjectCacheWorker).to receive(:perform_async).with(new_project.id, [], [:lfs_objects_size]) + expect { described_class.link_to_project!(subject.lfs_object, new_project) } + .to change { described_class.count } + + expect(described_class.find_by(lfs_object_id: subject.lfs_object.id, project_id: new_project.id)).to be_present + end + end + describe '#update_project_statistics' do it 'updates project statistics when the object is added' do expect(ProjectCacheWorker).to receive(:perform_async) |