diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-11-02 11:18:21 +0300 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-11-02 11:18:21 +0300 |
commit | 80032a84dcaa06774a553863c48f011c3ec53367 (patch) | |
tree | c6e4b287cb7f4f213faa7ffa5e915c7d479a6918 /spec/workers | |
parent | e90a555745fd99673916038ae053879a45462a6f (diff) | |
parent | 90072d61e167915a95c26a9af438ef5b6f1f0b03 (diff) |
Merge remote-tracking branch 'upstream/master' into pipeline-notifications
* upstream/master: (216 commits)
Remove invalid changelog entries
require rails/generators for generators
Adds variable. Fixes changelog
Fix haml_lint
Fixes after review
Update changelog
Remove tooltips from project header
Makes table pagination responsive
23545 Fix distorted project and group avatars
Fix spinach tests
Update links in side nav and header
Allow to search for user by secondary email address in the admin interface
Rename :name search parameter to :search_query at /admin/users
Initialize Sidekiq with the list of queues used by GitLab
Fix project features default values
Add a link to the Issue Boards API in main README
Add validation errors to Merge Request form
Fix Markdown styling inside reference links
Fix relative links in Markdown wiki when displayed in "Project" tab
Adds label description to issue board title
...
Diffstat (limited to 'spec/workers')
-rw-r--r-- | spec/workers/project_cache_worker_spec.rb | 20 | ||||
-rw-r--r-- | spec/workers/remove_unreferenced_lfs_objects_worker_spec.rb | 55 |
2 files changed, 75 insertions, 0 deletions
diff --git a/spec/workers/project_cache_worker_spec.rb b/spec/workers/project_cache_worker_spec.rb index f5b60b90d11..bfa8c0ff2c6 100644 --- a/spec/workers/project_cache_worker_spec.rb +++ b/spec/workers/project_cache_worker_spec.rb @@ -5,6 +5,26 @@ describe ProjectCacheWorker do subject { described_class.new } + describe '.perform_async' do + it 'schedules the job when no lease exists' do + allow_any_instance_of(Gitlab::ExclusiveLease).to receive(:exists?). + and_return(false) + + expect_any_instance_of(described_class).to receive(:perform) + + described_class.perform_async(project.id) + end + + it 'does not schedule the job when a lease exists' do + allow_any_instance_of(Gitlab::ExclusiveLease).to receive(:exists?). + and_return(true) + + expect_any_instance_of(described_class).not_to receive(:perform) + + described_class.perform_async(project.id) + end + end + describe '#perform' do context 'when an exclusive lease can be obtained' do before do diff --git a/spec/workers/remove_unreferenced_lfs_objects_worker_spec.rb b/spec/workers/remove_unreferenced_lfs_objects_worker_spec.rb new file mode 100644 index 00000000000..6d42946de38 --- /dev/null +++ b/spec/workers/remove_unreferenced_lfs_objects_worker_spec.rb @@ -0,0 +1,55 @@ +require 'spec_helper' + +describe RemoveUnreferencedLfsObjectsWorker do + let(:worker) { RemoveUnreferencedLfsObjectsWorker.new } + + describe '#perform' do + let!(:unreferenced_lfs_object1) { create(:lfs_object, oid: '1') } + let!(:unreferenced_lfs_object2) { create(:lfs_object, oid: '2') } + let!(:project1) { create(:empty_project, lfs_enabled: true) } + let!(:project2) { create(:empty_project, lfs_enabled: true) } + let!(:referenced_lfs_object1) { create(:lfs_object, oid: '3') } + let!(:referenced_lfs_object2) { create(:lfs_object, oid: '4') } + let!(:lfs_objects_project1_1) do + create(:lfs_objects_project, + project: project1, + lfs_object: referenced_lfs_object1 + ) + end + let!(:lfs_objects_project2_1) do + create(:lfs_objects_project, + project: project2, + lfs_object: referenced_lfs_object1 + ) + end + let!(:lfs_objects_project1_2) do + create(:lfs_objects_project, + project: project1, + lfs_object: referenced_lfs_object2 + ) + end + + it 'removes unreferenced lfs objects' do + worker.perform + + expect(LfsObject.where(id: unreferenced_lfs_object1.id)).to be_empty + expect(LfsObject.where(id: unreferenced_lfs_object2.id)).to be_empty + end + + it 'leaves referenced lfs objects' do + worker.perform + + expect(referenced_lfs_object1.reload).to be_present + expect(referenced_lfs_object2.reload).to be_present + end + + it 'removes unreferenced lfs objects after project removal' do + project1.destroy + + worker.perform + + expect(referenced_lfs_object1.reload).to be_present + expect(LfsObject.where(id: referenced_lfs_object2.id)).to be_empty + end + end +end |